Cocoon emission in neutron star mergers