Yes, anyone can join a German Trade Union independent of citizenship.
Gewerkschaften in Deutschland or Trade unions in Germany
Unions are considered to be social policy coalitions that are especially protected under the constitutionally guaranteed right of forming associations for the preservation and promotion of working and economic conditions. Agreements that restrict or obstruct this right are therefore invalid and illicit (Basic Law for the Federal Republic of Germany, article 9, paragraph 3).
The German text describes further that Trade Unions can take on different legal forms of clubs:
Manche Gewerkschaften organisieren sich als eingetragener Verein und sind deshalb juristische Personen des Privatrechts. Andere Gewerkschaften sind keine eingetragenen Vereine, werden aber – wie politische Parteien – dennoch als rechtsfähige Personenvereinigung behandelt.
As in most European countries, basic laws (including constitutional rights) are valid for all persons within the country (including visitors).
Club membership is therefore free for all.
A Club, however, can restrict membership, but only when such restrictions do not contradicts higher laws (such as Human rights conventions).
Being a registered resident can be such a reason. Past history of a person another.
In the case of Trade Unions, not only are foreigners welcome but also a portional representation as Trade Union Officials is considered desirable.
In most cases (and is for ver.di) , 1% of your regular pay, before taxes, is the normal membership fee