Structural defects in ion crystals can be formed during a linear quench of the transverse trapping frequency across the mechanical instability from a linear chain to a zigzag structure. The density of defects after the sweep can be conveniently described by the Kibble-Zurek mechanism (KZM). In particular, the number of kinks in the zigzag ordering can be derived from a time-dependent Ginzburg-Landau equation for the order parameter, here the zigzag transverse size, under the assumption that the ions are continuously laser cooled. In a linear Paul trap, the transition becomes inhomogeneous, since the charge density is larger in the center and more rarefied at the edges. During the linear quench, the mechanical instability is first crossed in the center of the chain, and a front, at which the mechanical instability is crossed during the quench, is identified that propagates along the chain from the center to the edges. If the velocity of this front is smaller than the sound velocity, the dynamics become adiabatic even in the thermodynamic limit and no defect is produced. Otherwise, the nucleation of kinks is reduced with respect to the case in which the chargesare homogeneously distributed, leading to a new scaling of the density of kinks with the quenching rate. The analytical predictions are verified numerically by integrating the Langevin equations of motion of the ions, in the presence of a time-dependent transverse confinement. We argue that the non-equilibrium dynamics of an ion chain in a Paul trap constitutes an ideal scenario to test the inhomogeneous extension of the KZM, which lacks experimental evidence to date. © IOP Publishing Ltd and Deutsche Physikalische Gesellschaft.