Open terminal using ‘cmd.exe’
run the wsl with root user
type passwd <username> to modify the user password
Once done type ‘exit’ to exit wsl.
Now use wsl and check any command with sudo.
C:\Users\yodas>wsl -u root
root@localhost:/mnt/c/Users/yogi# passwd yogi
New password:
Retype new password:
passwd: password updated successfully
root@localhost:/mnt/c/Users/yodas# exit
logout
Source: Unable to change the root password in Windows 10 WSL – Ask Ubuntu