  We present the results of a series of 3D special relativistic hydrodynamic
simulations of a gamma-ray burst (GRB) jet in a massive circumstellar medium
(CSM) surrounding the progenitor star. Our simulations reproduce the jet
morphology transitioning from a well-collimated state to a thermal
pressure-driven state for a range of CSM masses and outer radii. The jet-CSM
interaction redistributes the jet energy to materials expanding into a wide
solid angle and results in a quasi-spherical ejecta with 4-velocities from
$\Gamma\beta\simeq 0.1$ to $\simeq 10$. The mass and kinetic energy of the
ejecta with velocities faster than $0.1c$ are typically of the order of
$0.1\,M_\odot$ and $10^{51}\,\mathrm{erg}$ with only a weak dependence on the
CSM mass and radius for the explored CSM parameter ranges. We find that the
numerically obtained density structure of the mildly relativistic ejecta is
remarkably universal. The radial density profile is well approximated as a
power-law function of the radial velocity with an index of $-5$, $\rho\propto
v^{-5}$, in agreement with our previous simulations and other studies, as well
as those suggested from recent studies on early-phase spectra of supernovae
associated with GRBs. Such fast ejecta rapidly becomes transparent following
its expansion. Gradually releasing the trapped thermal photons, the ejecta
gives rise to bright UV--optical emission within $\sim 1$ day. We discuss the
potential link of the relativistic ejecta resulting from jet-CSM interaction to
GRB-associated supernovae as well as fast and blue optical transients.
