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 126.96.36.199 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:188.8.131.52: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 184.108.40.206