Error trying to run script remotely from MDM

I am trying to use Mosyle for business MDM to push out brew to company laptops.

I have a script that installs XCode which seems to work, but I get an error installing brew:

==> /usr/bin/sudo /bin/mkdir -p /usr/local/bin /usr/local/etc /usr/local/include /usr/local/lib /usr/local/sbin /usr/local/share /usr/local/var /usr/local/opt /usr/local/share/zsh /usr/local/share/zsh/site-functions /usr/local/var/homebrew /usr/local/var/homebrew/linked /usr/local/Cellar /usr/local/Caskroom /usr/local/Homebrew /usr/local/Frameworks
sudo: no tty present and no askpass program specified
Failed during: /usr/bin/sudo /bin/mkdir -p /usr/local/bin /usr/local/etc /usr/local/include /usr/local/lib /usr/local/sbin /usr/local/share /usr/local/var /usr/local/opt /usr/local/share/zsh /usr/local/share/zsh/site-functions /usr/local/var/homebrew /usr/local/var/homebrew/linked /usr/local/Cellar /usr/local/Caskroom /usr/local/Homebrew /usr/local/Frameworks

I am not running it as root but using a default admin account. When I add that user to the sudoers file with command visudo, it works. This is kind of silly. I used visudo command as the account I was trying to use, so I could escalate locally to add the default admin but I can’t run the brew install remotely. Is there a way around this so I don’t have to put the password in the script in the MDM?

I don’t really know a way to get around sudo asking for a password when using MDM. But maybe the MDM vendor or a community dedicated to MDM would be a better place to ask.