Thermodynamics of a morphological transition in a relativistic gas