If you don't have filevault enabled, you can change your password via the macOS recovery (via google: https://nordpass.com/blog/how-to-reset-mac-password/)
if you do have filevault enabled, you'll either need your password to decrypt it in recovery mode. Not that if the issue is with the macOS installation, your password may actually work to decrypt your drive in recovery mode. If so, you should be able to reset your password using the steps in the link above.
Best of luck