GRADUALLY.
Get him excited about birds, or fetching a training dummy with wings tied to it, or something. Buy some .22 blank rounds, and when he/she is really excited or focused on a bird or a thrown dummy, fire the blank behind your back (or get someone else nearby). If done at the right time, the dog will hardly notice.
Do this once or twice an outing for a while, then you can fire the blank over the dog, and eventually increase the sound level by using a small shotgun (410) and then a 12. If the dog shows ANY signs of nervousness or distress at any point, stop, back up and start over.
DO NOT under any circumstance fire a 12 guage near your dog until it is accustomed to shooting and associating shots with retrieving a bird, or dummy, or whatever.
If you do it right your dog will love the sound of gunfire, because it means there is a bird to retrieve, somewhere.
What kind of dog?