Thanks very much for your reply, it's working a treat. I got a bit confused with all the different IP settings, so thought I'd post my solution here.
The Yahoo IM server runs off several hostnames, but the primary one I'm aware of is scs.msg.yahoo.com. This currently resolves to 18.104.22.168 and is used in the following scripts.
Please also not I'm running CentOS 5 so seem to have a slightly different iptables syntax to the one suggested. Its man page suggested that for my version, the DNAT target was valid in the OUTPUT, not POSTROUTING chain.
I've then modified my Yahoo client to use localhost:5050 as its server.
Once again thanks to datopdog for a great answer.
ssh -fN -L 5050:22.214.171.124:5050 -l myusername RELAY_HOST_IP
if [ "`whoami`" != "root" ] ; then
echo "you must be root to execute this script"
for protocol in tcp udp ; do
/sbin/iptables -t nat -I OUTPUT -p $protocol --dport 5050 -j DNAT --to-destination 126.96.36.199