The book, her first after the series about the schoolboy wizard, opens with the death of a parish councillor and is based around a local council election in a town which appears to be an English idyll but is at war with itself.
Gambon, who took on the role of Professor Dumbledore after the death of Richard Harris, will play delicatessen owner Howard Mollison in the TV show.
Other cast members include Julia McKenzie, who plays his wife Shirley, and Rufus Jones, who plays his son Miles.
Keeley Hawes stars as Miles's wife and Rory Kinnear plays Barry Fairbrother, whose death starts the story.
Filming starts on July 7 and the BBC1 series, made in association with US broadcaster HBO, will be shown in three one-hour episodes.