When I work with pups as young as 8 weeks I take them out into a field or wooded area. I have the pup off lead and they are usually very excited and curious at this point. I use a shotgun primer starter pistol and every so often I set it off.
When the pup is startled and stops to look around after hearing the shot, I turn to them and give lots of praise accompanied by a treat. Cut up hot dogs work GREAT. Cheap and easy to carry in a ziplock baggie.
It takes almost no time at all to get them to associate the shot sound with a positive experience. I can’t guarentee it will work with every dog, some dogs are just nervy, however I can say that all 3 of my dogs never had any issues with gunshots, fireworks, or thunder.