(Before doing this process, BACK UP THE CARD!!!!! Copy it's contents onto another sd card. If something wrong happens, the result could be TERRIBLE!)
To reset the password, You need to put the os sd card in another computer. Then, go on it, navigate to /boot/cmndline.txt like so.
Edit it; add at the end init=bin/sh
like this.
Then save the changes, and eject the disk. (In this, as you might notice, this file belongs to the computer's file system. In your case, you would alter the disk's file system. I am doing this on raspbian bullseye with a changed theme and this is just an example to give you an idea on how to do it.) Insert the disk into the pi, and boot it. The pi will not complete the boot, and you will have an error, and a blinking prompt. Type mount -o remount, rw /
and hit enter. Wait for the cursor, then, type passwd pi
and hit enter. Then, it will ask you for the new password. Type it, then push enter. If it says you have a weak password, then, make it stronger. When It likes your password, it will say "Password was changed successfully"
Then, type sync
and push enter. Then type exec /sbin/init
and push enter. It will do some processing, then ask for your login. Type your new password. Shutdown, and undo the changes that you made to /boot/cmndline.txt by deleting the init=bin/sh
part at the end of the line. Now, eject the card, put it back in the pi, boot, and you're all set!