Analytical solution for the modified nonlinear Schrödinger equation describing optical shock formation