The words are kind of similar, but not interchangeable. Dreary means boring or dull. Gloomy means dark, either literally or metaphorically. So more like sad, or negative in the sense of 'a gloomy forecast'.
The weather forecast for next week is gloomy.
The predictions for that stock's performance are gloomy.
I can't stand to stay in the library all day, it's so dreary.
That teacher's lectures are so dreary that I usually fall asleep in class.
You would actually not call a graveyard 'dreary'. Dreary does not have the meaning of 'depressing', 'scary', it just means stale, lifeless, uninteresting, etc.
Gloomy is like depressing, threatening, sad, etc.