You can use a dog's hunger at mealtime to help prevent or overcome gunshyness. It's going to take longer with an already gun-shy dog, or with a dog that is particularly sensitive to noise, but it will work for most dogs if you keep at it.
This method will work best if you're feeding a dry dog food, but it can be done with moist as well. Measure out the portion of food that the dog would ordinarily eat at its next upcoming meal. Take dog and gun somewhere you can fire and still keep dog safe while doing it. (Blank pistol will work best for this early training. if you don't have one and don't want to buy one, use a .22 or similar round. Leave the shotguns and centerfire rifles at home until much later in the training.) If you're using live ammunition, this is going to have to be at a range with no one else on it, or some other safe-to-shoot location that you can control totally.
Leave the dog in your vehicle or house while you set up. Spread out the food pieces on the ground at a place where you can watch the dog while you fire. Bring dog and gun to that place. Release dog and let it start scrounging for the pieces. Move as far from dog as you can and still keep control of the entire situation. When the dog has taken a few pieces of food, fire one round.
At this point, one of two things will happen. A young dog that is not gunshy and never will be will probably look at you, maybe back off a bit, and then resume scrounging. We will call this dog "Alpha." For Alpha, wait a couple minutes while it scrounges and then continue to fire a single round at a time, very widely spaced, until the dog is done eating. Stop firing. End of session # 1.
Repeat with Alpha at the next mealtime if possible, or at least within the next couple of days. When Alpha is utterly oblivious to the gun, amp up the rounds to whatever you'll be using for hunting with the dog. Start far away and work your way in to the dog with each new type of round. When the dog is oblivious to the hunting rounds while it scrounges, at any proximity to the gun, you're done with gunshyness training.
But if the dog ran off at the first round on the first day, or showed other signs of fearfulness that prevented it from eating, you'll need to proceed much slower. We will call this dog "Omega." Put the gun in a safe place away from you, out of sight if it frightens the dog by its mere presence. Encourage the dog to resume scrounging. Wait until it's well into the food. Pick up the gun and sit with it somewhere near the dog. You want the dog to start learning that the gun is no threat and that its presence actually is linked to the food. If the dog resumes scrounging, move far away and fire a single round. If dog shows substantial fear or anxiety from this second round, stop firing, put the gun away out of sight, and let the dog clean up. End of session #1 with Omega.
At the second training session with Omega, hold the unloaded gun but do no firing until the dog is about halfway through the scrounged meal. If the dog trembles or otherwise shows anxiety at the mere sight of the gun, put the gun on the ground at some distance but where the dog can see it lying there. Encourage the dog to resume scrounging until it is done eating. (You might have to sit among the dog food to show that it's safe to resume eating.) End of session # 2.
Now you will proceed very slowly with Omega, session by session with the unloaded gun. When the dog watches the gun occasionally while you carry it but seems fairly calm, move far away, load and and fire a single round. It might take a few sessions to get to this point, particularly with a dog that is already gunshy when you start.
By now you should be reading the dog fairly well and know how to proceed, based on the dog's reaction to the single fired round. When Omega can finish a meal without displaying anxiety, while you fire very widely spaced rounds, amp up the rounds to whatever you'll be using for hunting with the dog. Start far away and work your way in to the dog with each new type of round while it scrounges for the food pieces. When the dog is oblivious to the hunting rounds, at any proximity to the gun, you're done.
Yes, it may take a lot of time to get this done with an Omega. Don't rush things just because you start with an Alpha, either. This process will result in a dog that can accompany you in the field without fear of the gun. It is going to work best if there's no between-meal snacking provided by anybody in your house. As much as possible, feed only during the training routine, until there is no gunshyness.
Before you start hunting training with the dog, you may need to break the association between food and gun that you have worked so hard to accomplish. This is because eventually you want the dog looking for birds or bunnies, not food pieces, when the gun is being used. If the dog seems to be fixated on food scrounging when you're out with the gun, ignore the dog and fire some occasional rounds with the dog present. If you've done your gunshy work well, the dog will eventually get bored with the gun sound, and you can move on to hunting training in front of the gun.