I'm working in composing several times a week using my musical imagination and computer software. In the piece I'm working now I show the melody I created. For the next section, where I repeat the melody, I would like to show confusion by distorting the melody and/or its accompaniment. What are some techniques I could use to distort a melody and/or its accompaniment?
There are so many possibilities.... Think of the individual aspects of music, and ask how each of these could be changed. Here are some examples, but others may have additional suggestions. You may know about a lot of these already, but hopefully it gives you a starting point.
Timing. You could try speeding up or slowing down tempo. Or use a more free "rubato" tempo. You could also try changing meters (4/4 to 3/4, etc...).
Rhythm. You could make straight notes dotted (or vice versa), or hold out a note for an extra bar. Don't forget to consider more exotic rhythms, like a reverse-dotted ("Lombardic") rhythm, or the use of triplets, three-against-two, hemiolas (converting two groups of three into three groups of two, or vice versa), and the like. You can also change the rhythm of the accompaniment, for example by using long drawn out "pad" chords vs. using short, repeated rhythmic march-like chords, vs. adding an emphasis on the off beats (beats two and four). For a more classical technique, you can use "augmentation" and "diminution" (doubling and halving all the note values, respectively). For a more jazzy feel, try swinging the rhythm, and adding syncopations. You could even try shifting all the notes one beat earlier or later, though this is likely to make the melody sound quite different, and may imply certain changes in harmonies and note functions (e.g. passing tones becoming appoggiaturas).
Pitches. You could try shifting the melody (or part of it) into a different "inversion" (not the correct use of that term, but I'm comparing it to a chord inversion) -- what I mean is take the melody a third higher, or lower (or a fourth, or fifth, whatever works in your chord structure -- it doesn't have to be the same amount for every note). Similar to this would be a register shift, where you take something up or down an octave. You could also try an actual melodic inversion (different use of the word) by flipping the melody (or part of it) upside down. Similarly, you could use retrograde motion, and play it backwards. You could change steps into leaps or vice versa. If you keep the general contour and rhythm similar, you can even play around changing scale degrees and using chromatics, and still have the melody be vaguely recognizable. A great example of how to do this is Vi Hart's atonal version of "Mary Had A Little Lamb".
Ornamentation. Technically this a part of pitch, but its specialized enough to warrant its own section. There's a lot of different styles of ornamentation that you can add depending on your desired style. Trills, mordents, tremolos, glissandi, passing tones, appoggiaturas, or arpeggiations... I can't begin to list all the possibilities here.
Articulation. Try changing legato passages to staccato, or vice versa, or use different phrasing, or more advanced articulations/effects relevant to your instrument (e.g. harmonics on a guitar).
Harmonies. The existing answer mentions using secondary dominants, which is a great idea. There are also other chord substitutions -- such as changing between relative (or parallel) major/minor chords, using a suspended fourth (or second), tritone substitutions (for a jazz sound) -- as well as extending existing chords by adding sevenths, 9ths, 11ths, 13ths, etc. You can even also use chromatic "passing-chords" such as diminished and half-diminished chords. In general, what you want to look at here is functional harmony. Figure out where you have tonic, dominant, and predominant harmonies, and then replace them appropriately.
I haven't even gotten to mention changing instrumentation, dynamics, phrase structure (adding or removing bits), and accompaniment patterns. Experimentation is probably the word you want to keep in mind here.
Edit: Another good possibility is to add a countermelody, or other form of counterpoint. The goal here is to be rhythmically independent of the primary melody.
For the accompaniment you could try secondary dominants. There was a question about those not too long ago, you can find info about it there.
Transposition of a phrase is one possibility. Sequence (similar to transposition) is repetition up or down a fixed interval; this can be used several times in a row (changing harmonies) depending on the phrase itself.
Just changing an important chord to minor or major may work well; this emphasizes that particular chord (and its associated lyrics.)
Melodic inversion (mentioned in another answer) is useful (not to be confused with inversions of chords.) One picks a note and "reflects" the phrase about that note. A simple (but common) example is to keep the first note the same and then reversing the direction of each interval, retaining the size (usually diatonically). C-D-E-G becomes C-B-A-F (not a good example, but changing the B to a Bb may be good).
A weird (in my opinion) way is to just write the melody backwards; one can change the lengths of notes to make the new phrase sound better. Sometimes this works well. (This is a useful technique in counterpoint or in modern 12-tone composition.) A nice example is the 18th variation of Rachmaninoff's "Variations on a Theme of Paganini."