If the Change Passcode button is greyed out, it's worth checking who manages Screen Time on that Mac. In System Settings > Screen Time, see whether it says Family Sharing or lists you as a child account. If so, only the family organizer or parent can change or turn it off, from their own Screen Time settings.
If it is your own Mac and you set the passcode yourself, scroll down in Screen Time, make sure Lock Screen Time Settings is on, and click Change Passcode; use Forgot Passcode? and sign in with the Apple Account you used when you set it up. The Mac needs to be on the latest macOS and connected to the internet. Apple's overview is here: https://support.apple.com/guide/mac-help/get-started-with-screen-time-mchlfafa9773/mac
Is this Mac set up for family sharing or is it just yours?