I'll show you a way around this!
(Don't forget to read the notes on security below!)
  1. Start a new WSL session as you usually would.
  2. Type sudo EDITOR=nano visudo and hit enter
  3. Use your arrow keys to scroll to the end of the file
  4. Append the following username ALL=(ALL) NOPASSWD:ALL to the end of the file. Of course, replacing “username” with your user name.
  5. Hit CTRL + X and if asked to save, hit Y to confirm. When asked for the file name, leave the default and just hit enter.
  6. If you didn’t do any typos, that’s it! No more annoying password prompt inside your WSL session.

A note on security

This is the same way it’s done on a real Linux installation, and I would of course never recommend doing this on a real Linux installation for your user account.

But because in this case, this is contained within the WSL shell, I’d say it’s “okay” as long as you don’t run untrusted scripts or added dodgy repos to your WSL container. Because WSL can access all your files on your Windows side!

You should know, that this means that any script or application you run inside WSL as your user, which requests sudo, will be granted sudo privilege without password prompt. Follow this guide only if you know what you are doing.