Marinate the chicken: In a small pot, bring 4 cups of water to a boil. Remove from the heat and stir in the salt, sugar, peppercorns, 5 of the rosemary sprigs, 5 of the thyme sprigs, the smashed garlic, and the slices from 3 of the lemons. Pour into a large bowl, add 8 cups of cold water, then submerge the chicken in the brine, cover with plastic wrap, and refrigerate for 12–36 hours.
Position a rack in the center of the oven and preheat to 400°F. On a sheet of foil, place one of the heads of garlic, then drizzle with 1½ teaspoons of the olive oil and wrap to enclose; repeat with the remaining head of garlic and transfer to a roasting pan or large rimmed baking sheet.
In a small bowl, stir together the sumac and lemon zest. Drain the chicken, discard the brine, and use paper towels to pat the chicken dry inside and out. Using your fingers, gently separate the skin from the flesh and rub the sumac mixture under the skin beneath the breasts, thighs, and drumsticks. Transfer breast-side up to the roasting pan with the garlic bundles.
In a bowl, stir together the chopped garlic and remaining rosemary, thyme, lemon slices, and olive oil. Stuff the cavity with the rosemary, thyme, and lemon, then rub the outside of the chicken all over with the oil mixture and season with salt and black pepper to taste. Bake until golden brown and a thermometer inserted into the thigh reads 160°F, about 1 hour 10 minutes. Transfer the chicken to a cutting board (do not discard the pan juices) and let stand for 10 minutes.
To serve, carve the chicken and transfer the meat to a platter, then tent with foil. Unwrap the garlic, cut the heads in half crosswise, and squeeze the cloves into the roasting pan. Whisk the garlic into the pan juices, then pour the sauce into a bowl and serve alongside the chicken.