Tie the garlic, ginger, and allspice berries in a small cheescloth pouch. In a 3-qt.ovenproof pot, combine the beans, coconut milk, and 3 cups of water. Bring to a boil, reduce to a simmer, and cook until the beans are soft, 1-1/4 to 2 hours. If necessary, add more water during cooking to keep the beans covered.
Heat the oven to 350°F. Add the salt, pepper, thyme, and scallion to the beans. Add the rice and enough water to cover the rice by about 1 inch (about 2 cups). Bring to a boil and add the whole chile; don't break, crack, or cut the chile.
Cover and bake until the liquid is absorbed and the rice is tender, about 25 minutes. Remove the chile, thyme sprigs, scallion, and ginger-garlic pouch before serving.