No, I don't think there is an easy way to do it.
You might try something like this:
ssh -f remote "command; echo $$"
The -f obviates the need to use &, the only problem is, and I haven't done anything more than to make sure it returns something. The echo $$ probably isn't giving you back the commands PID, it's probably giving back something else.
However, it's a possible way to help in dealing with the messy nature of the script.
The other way to do it is in your script that you run, you can have it echo out it's PID to a file in /tmp and grab it that way instead of doing a `ps` on the machine.
|