Photo by Marcus S.
There's no dog that would bark on purpose just to annoy the neighbours. If your dog is barking while home alone, it's trying to signal it doesn't feel comfortable and happy because something is wrong. In order to fix the problem, it is necessary to know the underlying reason of barking and handle it. The reasons can be many, most popular being boredom, frustration, fear, territory protection, and separation anxiety.

Boredom and frustration

If a dog has nothing else to do but to bark, that's what it is likely to end up doing. Sometimes it can even get destructive. Try to think of something to keep the dog interested and engaged while you are gone. Make sure there are plenty of chew toys and bones available for your dog to play with. Try interactive treat toys (food puzzle toys), they could engage your dog for hours. Make sure the toy and treat are very safe and the dog cannot choke on them. If you have more than one dog, they are less likely to feel lonely (and, therefore, are less likely to bark) because they keep each other company.

Fear

Some dogs are afraid of thunder and loud noises they are not used to or not familiar with. If this is the case, you'll need to treat the root of the problem and help your dog overcome the fear. This will make both you and you dog happier.

Territory protection

Your dog may feel pressure to protect the territory since it finds itself the only member of the pack that is at home. It may also feel insecure in a large house because it doesn't know what to do with itself. Many people find crate training very effective in this situation. A dog crate can be a safe and comfortable place for your dog to rest when it's home alone. The crate becomes the dog's den, and the dog feels safe and secure inside it. If you plan on using a crate, it is best to start when the dog is a young puppy so it gets used to the crate.

Separation anxiety

It is probably the most common reason of barking when a dog is home alone. Does your dog bark when you're leaving the house, and you still hear it bark until you're out of range? If so, your dog is most probably suffering from separation anxiety. Separation anxiety sufferers are tightly bonded to their owners and act as if their world has ended when they are apart. These dogs may also run around the home, desperately chew on your possessions, or try to get out through doors or windows. If the owner returns while the dog is barking, its efforts in calling the family members back are rewarded, and the dog is therefore encouraged to repeat the unwanted behaviour over and over again. It's important to remember this and to handle the situation correctly.
So, what can be done? First of all, you'll need to get your dog used to the leaving process. Put on your coat and shoes and then sit on the couch, or play with your dog for a few moments, or make dinner. The more you do this, the less the dog will associate these actions with your leaving, and separation moments should gradually become less stressful.
Secondly, get your dog used to your leaving and returning for short periods of time. Make sure you return only when the dog is silent for a predetermined period of time. Reward when this goal is achieved. It may take a while to get this first silent success, but you must be patient and persistent. Begin with an easily obtainable goal, for example, 10 to 30 seconds. If the dog barks, set the timer back to zero. Once you have achieved your first success, re-enter the home, tell the dog "yes" or "good," reward it, and go about your business. Keep repeating the whole process increasing the time of your absence gradually. Some dogs will know about your presence on the other side of the door, so increase your distance after the first few repetitions to replicate departure.
Don't get overexcited about the silent success, especially the first one, because the dog will get overexcited too, and this is not what you want. Your return is not a great deal, it's just routine the dog needs to get used to. Wait until your dog is calm before entering the house. Do not shout for quiet, however, because most dogs prefer negative attention to none attention at all, and therefore they may find your shouts rewarding. It's actually never a good idea to shout when you communicate with a dog. The owner should always stay calm, confident, persistent and firm.
Crate training is known to work well to prevent and treat separation anxiety problems.
Last but not least, give your dog a sufficient amount of exercise on a regular basis. If a dog doesn't receive enough exercise to burn its energy, it can become overexcited and relentless, which can cause more barking.
No matter what the reason of your dog's barking is, it might be a good idea to let your neighbours know you are working on it. Their irritation will lessen once they know their complaints haven't been ignored.