how do you change a theme (melody) in music to make variations?

It is hard to answer that question in words, since I have no training in music theory. If you have the means to listen to some examples, I suggest Variations on (Mozart's) La Ci Darem la Mano by both Beethoven and Chopin, and any of the dozens of variations on Paganini's Caprice #24 in A minor, especially the one by Rachmaninoff (Rhapsody on a Theme of Paganini).

Jazz musicians do variations on a theme all the time.