I get little pieces of melody in my head, could be anything, a verse, some catchy lyrics, a guitar riff. Throw it around for a while and see what happens. No concrete step-by-step process. Some of my favorite guitar parts came from playing around with a ukulele, so don't discount anything in search of a great melody
As a guitarist, what I have to watch for, is writing 'guitar' music. Thats cool to the 3 guitar players in your audience, but 98% of all other people who hear a song like it for the melody, which is usually vocals related. Studying great pop songs from the golden era ~ AM radio from the 60's and 70's~ is a lesson in great songwriting. How to do a lot with a little.
Happy playing