Dungeons & Dragons Fifth Edition is a fantasy TTRPG first and foremost. However, it doesn't have to be pigeonholed into any one genre. A DM can take influences from any type of storytelling. In particular, many D&D 5e monsters draw on classic horror story tropes and elements, ripe for scaring players.
Source:https://www.cbr.com/dnd-5e-monsters-horror-one-shot/