The /etc/sudoers file dictates who is allowed to sudo to what account.
When setup up correctly:
sudo su - <someusername>
ls
exit # get out of sudo
requires no password.
If you set up so that you or whoever is running the script can sudo then the script will run without a passwoird prompt.