Can the theory of the second best mathematically justify labor unions in some scenarios? An EPI page says:

Some economists and policymakers might express unease at the view that the downsides of one deviation from “competitive” markets (either labor market frictions or market concentration or some other source of employer power) should be countered by introducing another market imperfection (e.g., unions or a binding minimum wage). But this unease is unwarranted. The “theory of the second best” clearly argues that once markets depart at all from perfect competition, efficiency may well be increased by further departures. For example, in the case of monopsony power in low-wage labor markets, legislated minimum wage increases can potentially move wages closer to efficient levels and increase employment.

However, looking at the theory of 2nd best... it's actually not that clear cut that one can simply infer that &quot;doing anything to counter&quot; a distortion is actually going to be 2nd best. In a 50-year retrospective Lipsey himself seems to have nothing to say about labor markets and his theory.
Further, as explained &quot;for dummies&quot; in an article in the Economist (which actually quotes from the above paper, but I'll just quote the more accessible, &quot;dumbed down&quot; explanation from the magazine itself):

Suppose that I told you that in the absence of the necessary conditions for teleportation, the next best thing is to forget all about the conditions for teleportation and instead fly at near the speed of light. Would you find this helpful if what you actually had was a Toyota and a half-tank of gas? Many &quot;second-best&quot; policy recommendations are a bit like that: the ideal market is a fantasy, so here is an ideal government to fix things. Obviously, this is not very helpful. [...]
The upshot is that in practical situations, as opposed to theoretical models, we do not know the necessary and sufficient conditions for achieving an economy-wide, first-best allocation of resources. Achieving an economy-wide second-best optimum allocation looks even more difficult than achieving the first best. Without a model of the economy’s general equilibrium that contains most let alone all of the above sources, we cannot specify the existing situation formally and so cannot calculate the second-best optimum setting for any one source that is subject to policy change. This is an important point since much of the literature that is critical of second-best theory assumes that economists know a distortion when they see one and know that the ideal policy is to remove the distortion directly, something that is necessarily welfare-improving only in the imaginary one-distortion world.

Lipsey himself says:

Are there general policy rules for piecemeal improvements?
My answer to the question in the [above] heading is &quot;no&quot;.

So is the EPI &quot;shooting from the hip&quot; here when it claims that 2nd best justifies minimum wage (and possibly even labor unions, although they're not as explicit about that entailment.) Is there any theoretical work that proves that labor unions achieve a 2nd best in some scenario?
Quoting your quote, emphasis altered by me:

The “theory of the second best” clearly argues that once markets depart at all from perfect competition, efficiency may well be increased by further departures. For example, in the case of monopsony power in low-wage labor markets, legislated minimum wage increases can potentially move wages closer to efficient levels and increase employment.

It seems to me the quoted Economist summary misrepresents this quite a bit! No one is claiming that unions or state intervention will yield the second best (which is a somewhat vague concept - what are the exact information constraints here?), merely that they may be welfare increasing.
To expand on this a bit: if we don't know where &quot;the competitive equilibrium&quot; wage would be, but people agree that it is in the [8,40] dollar range, then instituting an 8 dollar minimum wage policy would not have a detrimental effect and would be welfare improving in cases when the current wage is below \$8. But there is no claim of optimum, not even in expected value.
Mathing it up:
$$
\begin{align*}
S(p) &amp; = p \\
D(p) &amp; = a - p \ \text{ where } \ a \sim \text{U}[16,80]
\end{align*}
$$
so
$$
p^* = \frac{a}{2} \sim \text{U}[8,40].
$$

The paragraphs above are the gist of the answer, but I can also produce a hiperbole on par with the Economist. Suppose that I told you that due to variance in quality some lollipops manufactured by a certain company are detrimental to one's health. The Economist seems to argue, that someone proposing the idea of quality control is promising not that they will catch some of these poisonous lollipops but all of them. And since this is clearly not possible, as quality control itself has varying quality, it is pointless to even try to improve the situation. But quality control may be justified even if some of the subpar lollipops are discovered. In fact quality control may be justified even if it supervised by a nonexpert and hence only catches half as many subpar lollipops as possible, as stopping some bad effects are preferential to stopping none.
It occurs to me that given the difference between the marital ideal and the status of the average marriage it is rather fortunate The Economist does not give marital advice.