First we'll talk about the harm part:
Just like people, dogs can suffer hearing loss from REPEATED exposure to loud noises, HOWEVER, even though their hearing is more sensitive than ours, you shouldn't worry overly much about it....If it was a serious problem, all dogs would be deaf after exposure to a couple thunderstorms.
You can acclimate a dog to gunfire, simply by starting far away, with a "quiet gun" and moving gradually closer. Having the dog play(distraction), or get a reward for not reacting helps.
NOW, I have seen a (very)few dogs that are truly "gunshy", and they appear to be born that way, and we've never made any headway in breaking them of it. They usually react badly to thunderstorms and other loud noises as well.
My dogs (GSDs), because they've all been trained for Shutzhund Sport, get all cranked up when they hear gunfire....time to WORK!!!! 4th of July is NO fun around my house!