Heat oil in a large skillet over medium-high. Add onions and 1 teaspoon salt; cook, stirring occasionally, until onions begin to soften, about 10 minutes.
Reduce heat to medium-low; cook, stirring occasionally, until onions are very soft and deep golden brown, 45 to 55 minutes.
Stir in sherry, scraping bottom of skillet to loosen browned bits; cook over medium-low, stirring often, until liquid has evaporated, about 2 minutes. Remove from heat.
While onions cook, place Yukon Gold and russet potatoes in a large saucepan; add salted water to cover by 1-inch. Bring to a boil over high.
Reduce heat to medium; cook until potatoes are fork-tender, 15 to 20 minutes. Drain well into a colander. Pass potatoes through a potato ricer back into the same saucepan.
Add garlic, butter, and remaining 1 teaspoon salt to riced potatoes; stir until butter is melted.
Fold in egg yolks, caramelized onions, 8 ounces (about 2 cups) of the Gruyère, 1 ½ ounces (about 6 tablespoons) Parmesan, and thyme until evenly distributed.
Preheat oven to broil with rack about 6 inches from heat source.
Using an ice cream scoop, scoop potato mixture into mounds in a large broiler-safe baking dish.
Sprinkle each mound evenly with remaining 2 ounces (about ½ cup) Gruyère and remaining ½ ounce (about 2 tablespoons) Parmesan.
Broil until potatoes are heated through and cheese is melted and golden brown, 8 to 10 minutes.
Garnish with more thyme and cracked black pepper. Serve immediately.
