Does $E^2=(mc^2)^2+(pc)^2$ hold for light travelling in an optically dense medium? The rest mass of photon $m_0=0$ and photon travels at the speed of light in vacuum. So the energy of photon in vacuum is given by $$E_{vacuum}^2=(m_0c^2)^2+(pc)^2=(pc)^2$$ $$E_{vacuum}=pc=\gamma m_0c^2$$
As photon travels at the speed of light $\gamma= \frac{1}{\sqrt{1-c^2/c^2}}=∞$ and $m_0=0$, so energy takes the form $E_{vacuum}=∞\times0$ which can have a finite value.
But if light travels in glass ($μ=1.5$) the speed of light becomes $\frac{2c}{3}$ so $\gamma= \frac{1}{\sqrt{1-\frac{4c^2}{9c^2}}}=1.34$     a finite value. In this case, energy of photon in glass becomes $E_{glass}=pc=\gamma m_0\frac{c}{μ}c=1.34\times0\times\frac{c}{μ}\times c=0 $
Why am I getting the energy of photon in glass as zero when I apply the equation  $E^2=(m_0c^2)^2+(pc)^2$?
 A: When we say, the speed of a light in a medium, we are actually referring to the average velocity of light, I'll explain myself.
Think about only one photon reaching the "dense medium", as we know from quantum electrodynamics, light interacts with charged particles, and this dense medium, is nothing but a lot of charged particles: protons, neutrons(even they interact with light because they are "made of" charged quarks), electrons...
So if this photon enters the medium, it will interact, or not, with the rest of the particles, resulting that the time it takes the photon to escape from the medium, may, or may not fulfill the relation c=L/t with L the lenght of the medium, I mean, it may interact with no particle, it may interact "a bit" or it may interact "a lot". So the velocity of light in a medium is more like the average velocity it takes a photon to escape from the medium.
Now think about neutrinos, they are massive particles, so they do not travel at speed of light, but their interaction with matter is so weak, that in some mediums, we see that they go faster than light. https://physics.stackexchange.com/questions/94138/do-neutrinos-travel-faster-than-light-in-air#:~:text=Neutrinos%20will%20travel%20faster%20than,%2Fs%20and%20n%3E1.
Also I want to remark that your calculation is wrong. For massless particles, the relation $E = \gamma m$ does not hold, instead you should use $E =\frac{p}{\beta}$ with $\beta = v$ (all this with units c=1, I'm sorry).
What you should finally understand is that you are using microscopic arguments, to directly solve a macroscopic problem. Understand macroscopic behaviour from microscopic behaviour is possible but complicate, and needs to use average of certain properties between a lot of complicated stuff, for example the famous $T\propto mv^2$ from the kinetic theory of gases that relates the temperature of a gas with the squared average velocity of its particles.
I hope I made my answer clear, if not whe can still comment on this!
A: from refractive index wiki

In optics, the refractive index (also known as refraction index or
index of refraction) of a material is a dimensionless number that
describes how fast light travels through the material. It is defined
as
n = c/v , 

where c is the speed of light in vacuum and v is the phase velocity of
light in the medium

Matter is mostly made of vacuum and light always goes at the speed of light so the speed of light doesnt change in an "optically dense medium", it's the phase velocity that changes.
How you could experimentally distinguish the speed of light from the phase velocity in an optically dense medium, that I wish to know.
