Here is a video showing Lionel Air Whistles in action. It consists of postwar locomotives, but the air whistle units follow the prewar designs.
In terms of servicing the whistles, the usual suspects have reproduction/used parts available. Some places even sell complete (used/refurbished) whistle units. But like @Lionelski stated, if you have the patients to tinker and scavenge, that is the best bang for your buck.
Here is a video showing the insides of a postwar air whistle:
The Lionel Service Documents (and the reproduced LCCA/HSL Digital Archive, Aurotech, and Greenberg Publications) have quite a bit of information on the various air whistle implementations including exploded diagrams and parts lists like this:
Here is a representative prewar "bananna" air whistle unit:
Lionel continued to use an evolution of the air whistle into the 1990s, but instead of a relay and AC motor, uses solid state electronic trigger switch and DC motor:
If you are looking to get an air whistle on your layout and were seeking to do so by adding something to a locomotive, I would suggest that you just get a complete air whistle tender or look into getting one of the Lionel Whistling Stations that have the same air whistle enclosed in a building rather than a tender (this also has the benefit of not having to worry about potentially pesky relay):
Lionel Whistling Station Examples: https://www.google.com/search?...onel+whistle+station
As to being realistic - you can be your own judge. Some say it is more realistic as the mechanism of resonating air/steam are extremely similar and therefore desireable whereas others swear by the faithfulness of an electronic recording reproduction.
Now, before you ask, I'd figured I would address how the whistle is triggered. The locomotives run on low voltage AC. When the horn button is pressed, a DC offset is applied to the AC, which is then detected by the locomotive circuitry ("DC" relay) to activate the sound. In modern times, it is worth noting for the bell, a DC offset of opposite polarity is applied to the AC, which again is detected by the locomotive circuitry to activate the appropriate sound. For the curious, an oscilloscope shows this quite well.