It's no secret that the horrors in ghost stories almost always serve as signifiers for the horrors in society. Beloved's ghost is the legacy of slavery,* and Dracula represents the evil of aristocracy or Victorian sexual repression (depending on who you ask). The following three novels each tackle society's ills by literalizing those ills in creepy ways.
A House with Good Bones by T. Kingfisher: In Kingfisher's contemporary Southern Gothic, the haunting Sam and her mother, Edith, are dealing with represents a legacy of prejudice and sexism disguised by good manners and polite behavior (and how easy it is for victims to become perpetrators). It's a Kingfisher novel, however, so the horror is mitigated with humor and a goofy familiar (a vulture, in this case).
Lost Among the Living by Simone St. James: Set in England, 1921, the novel's Wych Elm House (and the protagonist) is haunted by the trauma of both mental illness and WWI. That trauma was heavy to read about, but St. James is rapidly becoming a favorite writer for her ability to combine mystery, romance, and spookiness.
Starling House by Alix Harrow: the most explicitly horror-filled of the three, this haunted house represents not only slavery and misogyny but the ability of otherwise good people to look away rather than confront evil. This was a good story, and I appreciate how nothing played out quite like one would expect, but although the novel is not YA it read like it, especially in the behavior of the main characters and in the overwrought writing style. The latter in particular distracted from my enjoyment of the story.
*Don't get me started on the long-ago English professor who interrupted a really good discussion to ask if we thought ghosts were real.