WARNING: FOLLOWING POST CONTAINS SCIENCE
What people are saying here is essentially right (but with varying degree of accuracy).
The sonic boom is a transient pressure peak that happens when the pressure waves caused by aircraft's movement through air form a shock cone when traveling at or more than speed of sound. It is observed some time after the aircraft has passed (this time depends on perpendicular passing distance and atmospheric properties that define the speed of sound).
If you were traveling along the aircraft, you would not be hearing a sonic boom, because the shockwave is usually fairly stable in the aircraft's reference frame. The only thing is, if your vantage point was AHEAD of the shock cone, you would only hear sound of passing airflow, but the sound from aircraft would not be making it to you. Conversely, if the camera position was moved behind the shock cone, then you would suddenly hear the sound the aircraft makes.
Sonic boom itself should only be audible in fly-by views, but even though IL-2 supports doppler-shift in sound samples, it does not simulate the travel time of sound, or sound delays. All sounds played in the game are heard instantaneously. If the sound system actually supported delayed propagation of sounds, we would not be having this problem - the system itself would take care of producing a sonic boom in appropriate conditions.
However, as it stands, the best we can do is either the current system - which, by the way, is a pretty bad idea if you want my opinion - or figure out a way to make the game play different fly-by sound at Mach 1 and above.
The modeling of the shock cone limit for external camera sound would probably be a bit too complicated. However, fly-by camera sound would be reasonably simple to craft so that there would be the correct length of silence at the beginning of audio, then sonic boom as the aircraft passes camera point, and regular jet sound with doppler shift after that. I've noticed that the time from hitting fly-by camera key (F3) to passing of the aircraft tends to be the same regardless of the speed; the game just throws the camera further ahead when flying at higher speeds.
Therefore, the only piece of the puzzle missing would be some kind of code (probably java) that switches the fly-by sound sample if the condition of going faster than Mach 1 is true. This system would be quite a bit better than the current, completely fake sonic boom that only appears when speeds goes above Mach 1.
So there you have it, the probably best and simplest way to fake sonic booms in a way that at least appears to imitate how sonic booms happen in real world.
Whether or not this is possible, I leave to people with more complete understanding and skill of java coding for IL-2. I hope someone is skilled enough to implement this, as I think it would be a significant improvement for supersonic jets.