I circulate several 2022 MacBook Pros running MacOS 12.5.1 in an education setting. For security, every MacBook automatic boots to a default user that all patrons use. The MacBook then erases/resets after shutdown. So users do not use a password to login to the MacBooks. But sometimes users will push the power button on these MacBooks to put the computer to sleep, which locks the MacBook, logs the user out of the Mac, and requires my admin password to log them back in. Is there a way to disable the power button from logging users out of the MacBooks?
Are you just trying to disable the sleep button?
May be worth taking a look at this thread
Specifically this command:
defaults write /Library/Preferences/SystemConfiguration/com.apple.PowerManagement SystemPowerSettings -dict SleepDisabled -bool YES
Should be able to set as a config profile if it works for what you need