The Quiet Method
Once your dog starts barking in the presence of a stranger, let them bark a few times. Then, gently hold their muzzle and say, Quiet. Avoid shouting, as that produces negative reinforcement. Take your hands off their muzzle. If they remain quiet, reward them with a treat.