Also, apps on modern Android are mostly sandboxed so they wouldn’t be able to “block” your phone on their own unfortunately. You could have one that You make/install that could do “things” but you’d be really limited without root access to your phone.
As for the phone locking when you plug it, you can make an app that detects when the phone is being charged. What I don’t remember is if you can force-lock your phone from user space Android-provided APIs. Keeping it on while plugged is possible by checking the appropriate checkbox in the developer settings “keep screen on when plugged”.