These issues can be handled by, and are best handled by a mechanical implementation. If the bed is heavy and is belted and is dropping/sagging when de-energized, it’s best to use a gear ratio to give the stepper motor’s detent torque the mechanical advantage.
Larger motors with higher detent torque can be used as well.
If you need some ideas to achieve this, look at Voron 2.4’s Z gearbox. A 16T pulley and an 80T pulley are coupled with a belt to provide an 80:16 gear ratio. The same principle can be carried over to any other application. Of course this means some work on your end to find what’s best, but it’s a start.
The only other thing I can think of would be an electronic brake using relays tied to a winding for the motor or something like that, but there is some risk there.
Best of luck! I am eager to see what you come up with.