Grease the bottom of a 13 by 9 by 2-inch baking dish or other shallow 3-quart baking pan.
Butter each bread slice on one side. Stack the bread, 6 at a time, and cut on the diagonal into triangles. Place half of the bread pieces, buttered sides down, in the bottom of the prepared dish. Scatter the goat or feta cheese over the bread in one layer. Scatter the cherry tomatoes over the cheese. Top with the remaining buttered bread pieces, buttered sides up.
In a bowl with a whisk, beat eggs, milk and pesto until well-blended. Pour over the bread and cheese mixture in the dish. Tamp down the top pieces of bread lightly with the back of a fork so that they soak up some liquid. Sprinkle the top with the grated cheese. Cover the dish tightly with foil and refrigerate overnight.
To serve, remove the dish from the refrigerator and place it in a cold oven; turn the oven on to 350 degrees. Bake for 35 minutes with the foil on; remove foil and continue to bake until pudding is puffed and golden brown on top, 25 to 30 more minutes.