Combine the onions, 2 tablespoons of the oil, and ½ teaspoon of the salt in a large deep skillet over medium heat. Cook, stirring occasionally, until the onions become soft and deep caramel brown, about 55 minutes. Stir in a little water now and then to prevent burning. Remove the onions to a bowl (you should have about ¾ cup).
Add the apple, ¾ teaspoon of the thyme, and the remaining 1 tablespoon of oil to the skillet and cook until the apples are browned all over, 4 to 6 minutes. Remove the pan from the heat, stir in the onions, and set the mixture aside.
Heat the oven to 425ºF. Beat the egg in a spouted cup and pour all but 2 teaspoons of it into a medium bowl. Whisk the sour cream, the cream cheese, 1 tablespoon of the Fontina, 1 tablespoon of the Parmesan, the pepper, and the remaining ¼ teaspoon of salt into the egg in the bowl. Set the leftover egg in the cup aside.
Coat a rimless baking sheet or the back of a rimmed baking sheet with cooking spray. Roll the piecrust into a 14-inch circle directly on the sheet or on a floured work surface; if using a work surface, fold the rolled crust into quarters and unfold it on the prepared baking sheet. Sprinkle on 2 tablespoons each of the Fontina and Parmesan, leaving a 2-inch border around the perimeter of the dough. Spread the sour cream filling over the top; then scatter on the onion-apple mixture. Top with the remaining Fontina and Parmesan. Fold the uncovered crust border over the edge of the filling, pinching the dough to create five or six pleats around the perimeter.
Brush the reserved beaten egg over the exposed dough. Scatter on the remaining ¼ teaspoon of thyme. Bake the galette for 15 minutes; then reduce the oven temperature to 375ºF. Continue baking until the filling is set and the crust is golden brown, 15 to 20 minutes more.
Tip: You can do the time-consuming step of caramelizing onions in advance; they’ll keep tightly stored in the fridge for up to a week.