Here's the method I've used and it works if you're consistent: (Here's an exception to the rule about waiting for the behavior before adding a cue. Here, it is just the opposite)
Put the barking on cue...say "speak" or "bark" (whatever cue you want, just keep it the same) You can use a hand signal too if you want. I open and close my fingers against my thumb like my hand is imitating a mouth, like you'd do with kids when they talk too much.
Immediately after you cue (not more than a second or two after, get the dog to bark by having someone knock on the door or whatever else will make him bark.
Dog barks.
Praise..."gooooood!" (no treat, just a little praise)
Give cue...."quiet" or "enough" (I use enough, but whatever you choose, just make it the same.) And immediately after, show the treat to prompt quiet....hold the treat in front of his nose...get him distracted until he is quiet. Hold the treat for 3-5 seconds and then give it to him.
Repeat with less and less visibility of the treat prompt but still give it to him after perfect 3-5 second quiets.
Repeat with longer and longer durations of quiet before giving the treat.
Practice with lots of visitors or whatever else triggers the barking. Vary them.
Do it over and over till the dog gets onto this game. And it is a game. It my take a few sessions so keep it up. You'll know that the dog gets it when he barks on the cue and doesn't need the door knocking or other noises to set him off. And he quiets on the first cue to quiet without being shown the treat. Still give him a treat but take it from somewhere he won't notice so much, like your pocket or a table top. (later, once reliable, you'll put the treats on a variable reinforcement schedule)
If he ever starts to bark during a quiet time with even a half attempt at a bark or a tiny soft bark, tell him "woops" (a no reward marker) and start your count over again....1,2,3,4,5...He has to know that barking during the quiet time lost him the treat. He needs to give you 3-5 seconds of perfect quiet after you cue the quiet.
Practice this by going back and forth, back and forth between the cue to bark... and the cue to quiet...lots of times before trying it out in real situations. Set up the situations so you can practice better. Expose him to a wider variety of sights and sounds if he is especially easily set off.
Many people give up because they never get past the hard part. Memorize the instructions and understand them completely. Practice, practice. This process works if you give it ample training. It can seem like it's going nowhere the first few times and most people never make it past the initial hard part. The first few times, the dog will respond poorly so you must be ready with some very tasty treats. If he messes up once you've decreased the visibility of the treats for a while, go back to showing him them again for a bit. (Often, dogs that have been trained using more traditional methods take a while to get onto the game because they haven't learned about doggie zen) They’re not accustom to controlling their own behavior because someone else is controlling it for them.
When he's been doing this for a while and he barks after being told to "quiet," he must get an instant time out away from the action, which most dogs find fun and stimulating. Having to leave the excitement really bothers most dogs. Timing, of course is vital as always. Once you've given the "quiet" cue and he barks, he must immediately get a "Woops" (too bad for you) and he is quickly removed to the isolation area. Do not let him out if he barks. Wait for a lull of about 5-10 seconds first after having been in there for a minute or two.
You can also do a down-stay. A lot of dogs don't bark when they're lying down.
It is very likely that it will get worse before it gets better. Your dog has been barking for a long time this way and when something has been working and then it doesn't, he's going to try and try some more. The sudden shift in the rules will likely cause some confusion at first. But then there will be an extinction burst where by he tries and tries and the last time he tries before he gives up because it's not working, he's going to give it all he's got. Keep at it. This will pass. Once he finally gives up for good, the behavior will extinguish. It will extinguish because it doesn't work to bark. Nothing satisfying comes from the excessive barking and no behavior exists when there is no motivator. BUT...something better happens, that works better when he hears the word, "quiet." So that new behavior will be taken on.
The trouble with force based methods, intimidation, aversives and all that is that it tends to regress badly and often, fairly soon. I went that route for years and it never worked. Power struggles don't work. And primarily, it doesn't get at the root of the issue which could be a bad socialization history or some other fear or even excitement over seeing a dog pal. You don't want to escalate that. Associating the other dog or whatever triggers a dog to bark manically with that kind of punishment is that the dog is already stressed, emotionally and physiologically (heart rate, adrenalin, respiration levels are higher) and it further associates the trigger with more of a stressful time than he was already having. It doesn't help the dog to calm down. It only shuts a dog down so he looks calmer but he's "stuffing it." Showing the dog that good things happen in the presence of the trigger and for obeying your cue makes for a much more reliable skill and a much happier dog. It's also less wear and tear on the owner in the long run.
Once the behavior is quite well on it's way, practice this in different environments, locations, contexts and various triggers. Get the dog to generalize this behavior in any kind of situation, anyplace.
I have two yappy Chihuahuas and one loud mouth mix breed... and believe me, if any dog can bark, they can. LOL. I used this method and was lazy with one of my dogs. In the last week or so, I've been practicing better and let me tell you, the second they hear, "enough"....they all three stop barking in unison...absolutely suddenly and exactly together at the same second. It's great. They got the initial behavior going quite well in just one or two sessions. It took some more to get the cues independent of the prompt and the door knocking person.
It can also double as a fun trick to show people. "speak" and "quiet."