It is incorrect to state that there is a photon with energy $E$ in its rest frame, but it would be correct to talk about a photon with energy $E$ in some frame. In this case, the equation that you wrote would be valid to express the energy of that photon observed from a different frame (that you choose to characterize with a prime) that moves away with normalized velocity $\beta=\frac{v}{c}$,
$\displaystyle E^\prime = E \, \gamma \, ( 1 - \beta ) = E \, \sqrt{\frac{1 - \beta}{1 + \beta}}$.
This expression follows from exactly what you wrote. This result is the well known expression of the Doppler effect, and is valid for any $\beta < 1$. In the case of $\beta = 1$, you have found that $E^\prime = 0$. You cannot have an observer moving at the speed of light with respect to any other observer, so no one will ever measure $E^\prime = 0$ anyway. The somehow paradoxical idea that some observer would measure a zero energy is protected by the fact that no observer can ever reach the necessary speed for this to happen. However, you can think of a reference frame in the mathematical sense, moving at that speed. In this case your conclusion would be the same that it would be for a massive particle: in the rest frame where that particle is at rest, the energy is the rest energy, i.e. its mass (times $c^2$). In the (non-physical) frame with the photon being at (non-physical) rest, the energy of that photon would be its mass, i.e. $0$.