Well John, jump right in. There are circuits to do that. First, let me compare it to a diesel horn. You need the circuit. I have some. You need to get parts. The plans were developed in the 90's so you will have to order them, Radio Shack will not have them all. Some older ones are obsolete.Then, if train mounted you will need to activate it. The DCC guys just press a button. I do not know how to replace the relay electronically? All I know, is to have a reed switch activated by a magnet.
In my learning curve I am that far. Today sound products are available if you build just one it will not be cost effective to do it. I do it to learn so I did not buy store completed boards. Most people buy, for time saving reasons which is understandable. Me, I take one step at a time and show projects that I have built and present them.
There are four books by Peter Thorne The yellow book has a deluxe sound system but it is not on a train ,he does discuss sending sound through the rails. Sound Quality is also an issue. So far my horn sounds like a VW bug. I have it mounted on a bread board am plan to replace the pots with resistors to get a good sound.
I do not want to sound discouraging but those are the facts.
Modern train books? DOn't know of any. Today the stuff is bought cheep and building has taken a back seat.
Your answer at amazon
steam whistle for 11 bucks. That is a good deal maybe worth it to see it. It is a kit.
Bill Bowden and ROb Paisley have RR circuits but no sound producing ones.