Did Shakespeare invent the word gloomy?

No. Christopher Marlowe did, although Shakespeare used it three times in his early plays and poems. Marlowe was very fond of this word and used it 17 times.