You gotta build up to it.
The way I learned to do it is probably different from how other people did. I thought of it like this: first you need to be able to play the entire song with zero difficulty on its own, pretty much without even thinking about it. You also need to be able to sing the whole song on its own without even needing to think about it. Then you need to combine the two into a single thing. (Once you get good at singing and playing at the same time, you won't need to know both parts nearly as well).
I think of it like the guitar parts and the vocal parts being fused into one, much like how pianists are playing different things with their left hand and with their right hand, but together it makes a single song or melody. I think of the vocal melodies and so on as being a part of the song with the guitar that goes under it. When you first start doing this, it can be very hard, so you need to start with something simple and work your way up.
In my last band, I was playing parts in 11/8 shifting into 5/4 then 9/8 over drum polyrhythms while singing through all those changes. BUT I started learning how to sing while playing with Nirvana songs, which were basically the exact opposite. The first song I attempted was "Rape Me" which is very very easy to play and very very easy to sing, thus it's a great place to start. For metal, some of the early Black Sabbath songs can be a great place to start. "Iron Man," "N.I.B.," "Sweet Leaf," and so on.
Keep it up and you'll get it!