In my county it is legal to shoot dogs that are worrying or harassing livestock, and obviously if a dog comes onto your property and is behaving aggressively towards you, your pets or other animals, yes, it is legal in most areas. Rural areas see a lot of damage to livestock from marauding dogs. Chasing and injuring or running cattle, sheep, goats or horses into fences. Chasing and killing chickens and other poultry.
I love all animals but, admittedly, am not a big fan of dogs though I have had a couple I have loved over the years. I have zero tolerance for renegade dogs that might injure my pets. I have a 19 year old pet goose and if some dog was after him I would not hesitate to shoot the dog if I had a weapon handy. That’s the way it is, and protecting yourself and your other animals from an attacking dog or dogs is no different than any other type of self defense.
I have seen rabbits that have had their feet shredded and pulled through the bottoms of their hutches by roving dogs. Not a pretty sight.
Loose dogs are also a great hazard to horseback riders on trails, another instance where extreme force would be justified. Some very bad accidents and inures have occurred from dogs biting and spooking horses and their riders being thrown off their horse and the horse running away and injuring itself and/or running into traffic. Nothing fucking scarier than a dog coming at you and your horse on trail.
Dogs should be on leash and contained at all times to protect others, pets, livestock and wild life.
I have a huge problem with people letting their dogs chase and harass wild life as well, especially waterfowl which are prone to breaking their legs being forced to run on land.