We demonstrate that a highly charged polyelectrolyte confined in a spherical cavity undergoes reversible transformations between amorphous conformations to a four-fold symmetry morphology as a function of dielectric mismatch between the media inside and outside the cavity. Surface polarization due to dielectric mismatch exhibits an extra confinement effect, which are most pronounced within a certain range of the cavity radius and the electrostatic strength between the monomers and counterions and multivalent counterions. For cavities with a charged surface, surface polarization leads to an increased amount of counterions adsorbed in the outer side, further compressing the confined polyelectrolyte into a four-fold symmetry morphology. The equilibrium conformation of the chain is dependent upon several key factors including the relative permittivities of the media inside and outside the cavity, multivalent counterion concentration, cavity radius relative to the chain length, and interface charge density. Our findings offer insights into the effects of dielectric mismatch in packaging and delivery of polyelectrolytes across media with different relative permittivities. Moreover, the reversible transformation of the polyelectrolyte conformations in response to environmental permittivity allows for potential applications in biosensing and medical monitoring.