All you have to do is set the HLSL as usual, then:
monitor lcd
syncrefresh 1
Forcing -syncrefresh here makes all games run at 60 Hz (assuming a typical 60 Hz LCD). If you don't want this, i.e. keep games running at their native refresh if it's not close enough to 60 Hz, then leave -syncrefresh alone (default = 0), this will toggle either -syncrefresh or -triplebuffer depending on how close the native refresh is from 60 Hz. The threshold is controlled by the -syncrefresh_tolerance option (default = 0.2 Hz). Obviously, if you don't force -syncrefresh, you can expect scroll hiccups in games that don't run at 60 Hz, although you'll have no tearing.
The "monitor lcd" option also imposes that MAME will run everything at your current desktop resolution, which ideally equals your LCD's native resolution when you're using an LCD. I'm telling this because, quite often, users have to force MAME to pick a lower resolution than the native one in order to get HLSL run at full speed. If this is the case, then the "monitor lcd" is a bit of a problem, because it expects not to switch resolutions. What you have to do in this case is to lower the desktop resolution instead to the desired one for HLSL to work.