Those are legal, at least in the EU. It's called "push support" or "walk assist", my bike engages it when I long-press the down button. It's purpose is to help you push the heavy e-bike up ramps and hills, but I mainly use it as a throttle when I ride behind my toddler on his balance bike.
It's closer to 3mph than 5mph, and as such needs some slow-riding skills, but it works.
One of my bikes without a thumb throttle has this but there is a bit of delay from the long-press required which I don't like compared to the basically instant response of the thumb throttle. It also requires a bit for attention to press the small button vs the throttle you can keep your eyes on the road.
It's closer to 3mph than 5mph, and as such needs some slow-riding skills, but it works.