I set a password on my external HDD using disk utility. Now I am trying to access my HDD however, I cannot access it even if I am trying to give right password. Is there a way to reset this password without losing any data?
The purpose of disk encryption is to make it so that someone unauthorized (that is, who doesn't know the password) can't access your data. Being able to reset the password and still get at the data defeats the purpose.
If you used that drive on a different system, and you allowed that system to save the password so it could automatically access the drive, then there is a slim chance that it could be sitting that other machine's Keychain Access secret store. (Whereby you'd open the Keychain Access app, authenticate, scan all the list of entries for the one that looked like your drive, click it, likely re-authenticate again, and it'd [in theory] show you the password to use on the first machine.)
Other than that, set the drive aside and see if the password comes to memory at some point in the future. Reformatting the drive will lose the data. Trying to get at it without the password ought to look like jumbled bits -- and you certainly don't want to alter them for fear of corrupting the underlying information.
For the future, always-always-always squirrel device access and/or recovery passwords somewhere away secure, whether on paper or in a password vault (like 1Password, LastPass, or some other similar secrets manager).
Sorry this wasn't the answer you hoped for.