Of course you can. The problem is that you are virtually never allowed to carry any weapon in Public in Germany.
§32 Self-defense
(1) Whoever commits an act that is required by self-defense does not act unlawfully.
(2) Self-defense is the defense that is necessary to avert a present unlawful attack against oneself or another person.
§ 34 Justifying necessity
Anyone who, in a present danger to life, limb, freedom, honor, property, or another legal interest that cannot otherwise be averted, commits an act in order to avert the danger from themselves or another person does not act unlawfully if, upon weighing the conflicting interests—especially the affected legal interests and the degree of danger threatening them—the protected interest substantially outweighs the impaired interest.
However, this applies only insofar as the act is an appropriate means of averting the danger.
If someone steals your car in Germany, and that car is your lifelihood, you are allowed to shoot them, to stop the theft, even if the gun is illegal (that would be another charge). German self defense laws are quite good and cover any transgression even against third persons, but ultimately useless because it's so difficult to get weapons here and nobody wants to deal with the court system. But technically Chud would walk free even in Germany since he got attacked, the gun is legal and courts will not expect you getting into fist fights and he had no other means for protecting his life/body.
Are you sure you don't have a similar law in the US? I always had the strong impression of it.