What do you call it when the meaning of a word changes within a sentence?
This is called antanaclasis (OED: "The same word is repeated in a different, if not a contrary signification"; Merriam-Webster: "the repetition of a word within a phrase or sentence in which the second occurrence utilizes a different and sometimes contrary meaning from the first"), with many other examples provided at the link.