Close the WSL terminal, open Windows command prompt and make the default WSL user as root using the below command
ubuntu2004 config --default-user root
Open a new WSL terminal, you will be logged in as root.Type
nano /etc/sudoers
Now you can edit the sudoers file. Cheers!
Extra: ubuntu1804 config --default-user root
for Ubuntu 18.04 and above or ubuntu config --default-user root
for versions below.