The malicious code would run as your current user and would be able to override your shell’s configuration to alias sudo to a malicious function that’ll exfiltrate the password the next time you run it. The script itself doesn’t even have to use sudo itself and can just wait until you use it for an unrelated command at which point the malicious alias will steal your password.