while taking composition in school we had to do a verity of things.
-Write a blues tune
-write a modal tune (so what, saga of Harrison crab feathers)
-a standard practice in jazz is to write a new melody over an old standard.
- re harmonize an existing melody is a good exercise.
then there are the kind of weird ideas:
-mashing two penta-tonic scales into one scale (say adding all the notes from A penta tonic and B pentatonic, or adding A pentatonic and Eb pentatonic)
-take each note of a melody and using that as the bass note for a chord, then write a new melody
- invert a melody and reharm after (after the first note if the next note goes up a maj 3rd your new melody goes down a maj 3rd and so on)
- like the above but play a melody in reverse (last note becomes the first note) and reharm.
doing a lot of this will teach you what chord progressions you like and how to think creatively when you have an idea.
in class we talked about how some classical composers didn't have a lot of motifs but would move it around (in the violins, then the reeds, then the brass, then back to the violins but at Forte and an octave up, then a transposition to a new key, then staccato... etc
another thing is- once you have a melody- shift it around. start on beat 1, start on beat 2 and adjust to make sure the notes fit the harmony.
or elongate /compress it, turn a 4 bar iii-iv-ii-V with quarter notes into a 1 bar with triplets.
If you are used to playing jazz and improvising solos writing a song is very similar thought process. there are endless patterns to practice and endless scale/chord relationships that work. Writing a good tune can just be putting in a lot of work.
and one final tidbit, don't be afraid to leave space.