You can stop a dog from barking when left alone or anytime you don't want the dog to bark by buying a bark collar.
The bark collar is an effective and humane way of stopping a dog from barking too much.
The bark collar works by sending vibrations that the dog doesn't like and when they start to bark they'll feel that vibration and learn that when they want to bark they'll feel that vibration if they do and they won't want to bark when the bark collar is on.
There are some bark collars that will send a shock to the dog though so I would recommend checking to make sure the bark collar just emits vibrations and not a shock.