Try getting your IM client to run a simple Python script that just logs a message to standard out. Hopefully, that message should get sent to the standard output of the IM client, which in turn will be passed over SSH - then it's just a matter of parsing the SSH client's standard output client-side.
If the IM client redirects the script's output, then you may have to do something else to pass the message along. You can create a named pipe on the BSD machine, then when you connect, run the IM client in the background (add an "&" to the end of the command-line). Then cat the named pipe in the ssh session. You can then have your python script write a line of text to the named pipe when the message arrives. http://en.wikipedia.org/wiki/Named_p..._pipes_in_Unix
The client-side processing should be fairly easy. Once you have the message-sending working, you can just pipe the output of ssh into a python script (add "|/path/to/script" to the command-line), and then use that to play your sound when a message arrives.
Hope that helps,
–Robert J Lee