  Consider the free energy of a $d$-dimensional gas in canonical equilibrium
under pairwise repulsive interaction and global confinement, in presence of a
volume constraint. When the volume of the gas is forced away from its typical
value, the system undergoes a phase transition of the third order separating
two phases (pulled and pushed). We prove this result i) for the eigenvalues of
one-cut, off-critical random matrices (log-gas in dimension $d=1$) with hard
walls; ii) in arbitrary dimension $d\geq1$ for a gas with Yukawa interaction
(aka screened Coulomb gas) in a generic confining potential. The latter class
includes systems with Coulomb (long range) and delta (zero range) repulsion as
limiting cases. In both cases, we obtain an exact formula for the free energy
of the constrained gas which explicitly exhibits a jump in the third
derivative, and we identify the 'electrostatic pressure' as the order parameter
of the transition. Part of these results were announced in [F. D. Cunden, P.
Facchi, M. Ligab\`o and P. Vivo, J. Phys. A: Math. Theor. 51, 35LT01 (2018)].
