GrapheneOS[1] has that option in the security settings. I have mine set up so it automatically reboots the device if I haven't unlocked it in the last 8 hours.
I suspect that maybe the most intrusive malware could prevent this or even fake it to the software, better to restart yourself
Think of holding down the power key for some seconds as a Secure Attention Key that forces control of the device away from the exploit. Automatic reboot might catch some exploits, but the SAK and trusted boot after it gets (practically) all of them.
I think a malicious rootkit could just show a fake power down / power up sequence.
Or just disable it completely
Looks like this can be done with Shortcuts.app on iOS.