There are many U.S. jurisdictions in which some public sector employees cannot unionize, and in the U.S. the right of most kinds of private sector employees who aren't part of management (although not all) to unionize, is secured by federal law (the National Labor Relations Act). Unsurprisingly, unionization of federal government employees is also governed by federal law.
Management workers in both government and the private sector are not generally permitted to unionize (including almost all government lawyers and judges and all military personnel, for what it is worth).
Federal law (other than the U.S. Constitution) does not apply to public sector unionization at the state and local level in the U.S., for federalism reasons.
Wikipedia reviews the relevant U.S. history. Postal service unions first arose in 1890 and have persisted to the present. Other public service unions emerged, such as the Boston Police Union, but a strike by that union in 1919 resulted in the elimination of public sector unionization in the U.S. (outside public schools and the post office) from 1919 to 1958. Public sector unions in the U.S. have expanded rapidly since then. Federal government unions outside the postal service were legalized in 1962.
In 2010 8.4 million government workers were represented by unions,
including 31% of federal workers, 35% of state workers and 46% of
In the United States in the year 2020:
The union membership rate (the percentage of wage and salary workers
who were members of unions) was 10.8 percent. . . .
the union membership rate in the public sector . . . [was] 34.8
percent, while the rate in the private sector . . . [was] 6.3 percent.
Public sector unions typically afford a different mix of benefits for members than a typical private sector union does.
Public sector workers have had many union-like benefits such as defined benefit pension plans and the right to be fired only for cause (two of the main goals of many private sector unions), for much longer than public sector unions have been widespread. The federal civil service system was begun in 1883 in reaction to abuses of political patronage by prior administrations, especially that of President Andrew Jackson.
There continue to be many cases in the U.S. where government workers can unionize, but not strike, either due to a global rule that applies to every unionized government workplace of that type in that jurisdiction, or due to a widely adopted collective bargaining agreement term.
For example, unionized federal government employees don't have the right to strike, as a matter of federal statutory law.
Some Brief Comparative Observations About Private Sector Unions
What a union does and means varies from country to country.
For example, the main kind of private sector union in Japan, which is sponsored by the company itself, is prohibited under the National Labor Relations Act in the United States.
Similarly, while U.S. unions are organized primarily on an employer by employer basis (with a few notable exceptions like people in the live theater, TV and film industries), some countries have unions organized on an industry by industry basis.
Private sector unionization in the U.S., in contrast to public sector unionization, has declined more or less steadily since about 1970, mostly due to outsourcing and off shoring that is not feasible for many kinds of government workers (a full analysis of that point is beyond the scope of this question).