It seems in Big Sur the file you need to edit is not writable. So you need to make it writable first, edit it, and then change permissions back to read-only.
Have confirmed that using 'sudo nano /etc/pam.d/sudo' works fine.
No need for the verbosity when nano works I guess. :S