If the display and controller of your bike does not have a built-in cruise control, you'll have to resort to some sort of mechanical method of locking the throttle.
Who would make them illegal and why. A number of E bikes have a feature that maintains the throttle position and speed if you have held that speed for a period of time.