  In the gravitational wave event GW170817, there was a $\sim 10$ hours gap
before electromagnetic (EM) observations, without detection of the cocoon. The
cocoon is heated by a \textit{short} gamma-ray burst (\textit{s}GRB) jet
propagating through the ejecta of a Neutron Star (NS) merger, and a part of the
cocoon escapes the ejecta with an opening angle of $20^{\circ}$--$30^{\circ}$.
Here we model the cocoon and calculate its EM emission. Our 2D hydrodynamic
simulations suggest that the density and energy distributions, after entering
homologous expansion, are well-fitted with power-law functions, in each of the
relativistic and non-relativistic parts of the escaped cocoon. Modeling these
features, we calculate the cooling emission analytically. We find that the
cocoon outshines the r-process kilonova/macronova at early times (10--10$^{3}$
s), peaking at UV bands. The relativistic velocity of the cocoon's photosphere
is measurable with instruments such as Swift, ULTRASAT and LSST. We also imply
that energetic cocoons, including failed jets, might be detected as X-ray
flashes. Our model clarifies the physics and parameter dependence, covering a
wide variety of central engines and ejecta of NS mergers and \textit{s}GRBs in
the multi-messenger era.
