It depends on many things, the first one the age of the dog. It can be very difficult. Is the dog barking for attention, or because it is distressed, or is it a pup? Have you moved or changed its environment recently? As with most dog training, rewarding good behaviour is more effective than trying to punish. Most dogs are eager to please, once they understand what you want from them. If it reaches the stage of litigation (neighbours complaining etc.) you might have no recourse but to consider an anti-barking collar, one that sprays a harmless scent that the dog doesn’t like whenever it barks.