Decide what type of metal song you want to write. Several types of metal exist, from sludge metal to trash metal to death metal and beyond. You can mix and match different forms of metal when writing a song, but ultimately, you should have some idea of the kind of song you want to write.
Listen to a lot of songs in the type of metal that you plan on writing.To write music in a certain style, you have to have a very good feel for that style. It is also a good idea to learn how to play many of these songs on guitar.
Write a metal riff. Metal songs are almost always in minor keys, so play around with the minor scale when writing metal riffs. Don't be afraid to throw some chromatic notes into the mix. Metal uses chromatic tones more than most forms of popular music.
Write a chord progression that will serve as the verse or chorus of your song. This chord progression is usually in the same key as your riff. It is possible for your riff to work as either the chorus or verse, but all metal songs have more than one part. Don't be hesitant about adding single-note fills in with your chord progression.
Write the bridges, breakdowns, outros, solo sections and whatever other parts you think your song may need. You can experiment with changing keys and using other advanced musical techniques, but always make sure the parts sound good together. The most important thing when writing a metal song is to write something that you think sounds awesome.
Play your song for other musicians. If you are in a band, bring it to practice and see what everyone thinks about it. It is extremely fulfilling to hear the song you wrote on guitar played by an entire band. Listen to any criticism you get with an open mind. It is ultimately your choice what you do with your song, but the input of other musicians can be an invaluable tool when writing a song.