How to reset the Password for Scratch Org User (Salesforce DX)?
One option would be to generate the scratch org with the password already in place. Then you wouldn't need to change it.
See Generate or Change a Password for a Scratch Org User
By default, new scratch orgs contain 1 administrator user with no password. You can optionally set a password when you create a new user. Use the CLI to generate or change a password for any scratch org user. Once set, you can’t unset a password, you can only change it.
You can use
sfdx force:user:password:generate -u yourOrgAlias
If you want to check details
sfdx force:org:display -u yourOrgAlias