How do I set a Power off password?

Go to Settings > Security and privacy > More security and privacy and toggle Power off verify to turn it on.
Note: Power off verification protects your device by preventing others from turning it off immediately if it is lost, increasing the chances of recovery. You only need to enter your lock screen password when powering off or restarting the phone from the lock screen.