If the energy density becomes high enough electron-positron pairs will form. This limits the energy density of a photon gas. For example pairs can form in strong laser fields by multiphoton processes. It does not in principle require single photon energies of order $mc^2$. The so-called strong field Breit-Wheeler process happens of course at an energy scale much lower than that required for black hole formation. John Dvorak provided a Feynman diagram for such a multiphoton process. Here four photons convert into a positron-electron pair, if the sum of their energies is large enough. If it is not then a process involving even more photons will be the leading vacuum instability.
https://www.sciencedirect.com/science/article/pii/S2468080X17300183