You should try debugging/troubleshooting.
Change your current ssh command to
ssh host 'cd someDir; echo "The password is $password"'
You’ll get
The password is
Now try
echo host 'cd someDir; echo "The password is $password"'
You’ll get
host cd someDir; echo "The password is $password"
On your ssh command, you’ve got $password surrounded by double quotes,
and surrounded by single quotes around that.
Well, that turns the double quotes into plain, ordinary characters —
no more syntactically significant than if you’d typed LDQ and RDQ —
so $password is effectively wrapped in single quotes.
So $password gets sent to the remote host,
and not the value of $password (i.e., the actual password).
Then the shell on the remote host tries to expand $password to a value,
and it gets nothing, because that variable has not been set in that shell.
A command that might work is
ssh host 'cd someDir; echo "'"$password"'" | sudo -u nobody -S command'
Let’s examine that, adding spaces for illustration/clarity:
… '…; echo "' "$password" '" | sudo …'
This still has the double quotes inside single quotes.
But, after specifying the literal double quote (after echo),
it breaks out of the single quotes,
so variable expansion/replacement can occur on the local command.
Then we have $password in double quotes.
Then we go back into single quotes for the second literal double quote,
the vertical bar (|), and the sudo command.
Caveat: I don't currently have access to a host I can ssh into,
so I haven’t completely tested this.