Indeed there is. There are two ways you can go about it:
Method 1 (and the one I recommend):
This will turn on mouselook, meaning that you will be able to use the mouse to look up and down. This will prevent that any Y axis input in your mouse controls movement, as it will be used for looking instead:
Go to your options (esc > options) and select configure controls. Change 'Mouse/joystick aiming (mouselook)' to 'Always on'. I'd also recommend to invert the vertical axis and reduce your mouse vertical sensitivity, as the default setting is too sensitive.
Method 2:
If you don't want to enable freelook, you can use this alternate method that will also allow you to remove vertical mouse movement:
Go to your options (esc > options) and select configure controls. Reduce your mouse vertical sensitivity to 0, by sliding the bar all the way to the left and you can also optionally invert the vertical axis. With this method you can still aim up and down using the default keys or custom keys if you've setup any. Note that this will make toggle aiming very sluggish, but keys for aiming will not be affected.