I was able to do it by first hooking each group of vertices to a separate hook: select, CTRL + H, Hook to New Object:
Now in Object Mode select both hooks, in Object Constraint Properties tab add a Limit Scale constraint and set Minimum Y to 1
(perhaps you want to set the maximum too, if you want to move these groups apart).
Then press F3 and type Copy Constraints to Selected Objects (or choose it from Objects -> Constraints menu).
Now with both hooks selected, just press S, Y to scale them along Y axis:
Then copy