I assume the user1 does not have password-less sudo access, correct? If it does you can use the runuser command.
runuser -l user2 -c 'whoami'
You can just use su/sudo if you have sudo permissions setup.
su - user2 -c 'whoami'
However I assume you don't have password-less sudo and/or you may not have the password for user2. You could be tricky by generating an RSA keypair for user1 then appending the id_rsa.pub key to user2's $HOME/.ssh/authorized_keys file to enable RSA Public Key Authentication then use SSH to do it without a password.
As user1 run the following;
Just press enter through the prompts
Then run the following to add the key automatically (you can do this manually to). If you are using this command you will need user2's password the first time only.
ssh-copy-id -i $HOME/.ssh/id_rsa.pub user2@hostname
If this works you should be able to login as user1 then run ssh user2@localhost to login as user2 without a password. Make sure /etc/ssh/sshd_config on the server has PublicKey Authentication enabled.
Then to remotely execute command you can run something like;
ssh user2@localhost "remote-command1;remote-command2"