Can the energy of a photon be found out by using the most famous equation in all Physics, $E^2=(mc^2)^2 + (pc)^2$ ? If yes, then what will be the $p$ there?
The momentum of a photon is h/ℷ where ℷ is the wavelength and h is Planck's constant. The energy of a photon is hc/ℷ. In the equation you wrote, the rest mass of a photon is zero. Leaving you with E = pc.
$E$ is the total energy of the particle, $m$ is mass, $p$ is momentum and $c$ is the speed of light in vacuum. Photons are massless, so $m=0$, therefore the energy of the photon is: $$E=pc$$