Do you have another macOS admin user account available? If so, then you can correct the mistake by using the instructions in this Apple article as a guide (all steps must be followed):
Change the name of your macOS user account and home folder - Apple Support
If you don't have another macOS admin user account, then you can try restarting Setup Assistant to create a new admin user account which you can use to fix the mistake. If you are running macOS 10.15 to 13.x, then you can use the instructions in the following article to create a new admin user account, however, if you are running an earlier version of macOS, then the instructions can still be used as guide, but will need to be modified since the mount point will be named differently. After creating a new admin user account, you can use the linked article above to fix the mistake when renaming the user.
Restarting Setup Assistant to create Admin user - Apple Community
If you are running macOS 14.x Sonoma, then your only option is to erase the disk followed by reinstalling macOS & restoring from a backup since macOS 14.x does not allow Setup Assistant to be tricked into running again as it is a security issue.