This question was inspired by a recent Cool Worlds video "The Star That Shouldn't Exist", in which one of the speculative solutions to Przybylski’s Star's strange spectrum is aliens "salting" the star with heavy elements. This has raised much discussion in the comments section about how much one would need to alter the composition of the star in order to alter is spectral absorption lines, with the discussions making the implicit assumption that one would need to alter the composition of the entire star to make these changes. For the star in question; that would apparently require planet-scale masses of these elements, which to my mind removes any plausibility that the "salting" hypothesis might have had.
But is that true? Could it not be possible that a relatively small amount of an element "salted" in the surface of the star would have the same result as changing the composition of the whole star? Naively, I would expect the spectral lines to be "imprinted" on the spectrum in the photosphere, making the composition of the rest of the star largely irrelevant, at least in terms of absorption lines. So what determines the spectral lines: the composition of the whole star, the photosphere, or some other layer(s)?