Consider as a toy example a system with Gibbs free energy given by
$$G(p,T) = p^3 - 2p^2 - p + 2.$$
If I was to find the Helmholtz free energy, I would try Legendre transforming $F = G - pV$,
$$V = \frac{\partial G}{\partial p} = 3p^2 - 4p - 1$$
Solving for $p$,
$$p = \frac{2}{3} \pm \sqrt{\frac{7}{9} + \frac{V}{3}}$$
So
$$F(V,T) = G-pV = -2p^3 - 2p^2 +2 = -2\left(\frac{2}{3} \pm \sqrt{\frac{7}{9} + \frac{V}{3}} \right)^3 - 2\left(\frac{2}{3} \pm \sqrt{\frac{7}{9} + \frac{V}{3}} \right)^2 + 2$$
$$F(V,T) = -2\left(\frac{2}{3} \pm \sqrt{\frac{7}{9} + \frac{V}{3}} \right)^3 - 2\left(\frac{2}{3} \pm \sqrt{\frac{7}{9} + \frac{V}{3}} \right)^2 + 2$$
and apparently the free energy $F(V,T)$ is not even single-valued. How do I actually find the free energy as a function of volume, and how do I make sense of this result?