Preheat your oven to 375°F (190°C). Use a spoon to scrape out the dark gills from the underside of the portobello mushroom caps, then slice the caps into 1/2-inch thick slices. Toss the mushroom slices with olive oil, salt, and pepper in a large bowl until evenly coated.
Arrange the seasoned mushroom slices in a single layer on a rimmed baking sheet. Roast for 15 minutes, or until the mushrooms have released their liquid and are tender. Remove from the oven and set aside. Reduce the oven temperature to 350°F (175°C).
While the mushrooms roast, melt the butter in a large skillet or Dutch oven over medium heat. Add the sliced onion and cook for 8-10 minutes, stirring occasionally, until softened and translucent. Add the minced garlic and cook for 1 minute more until fragrant.
Sprinkle the flour over the onions and garlic and cook, stirring constantly, for 1 minute to form a paste. Gradually whisk in the milk and heavy cream until the mixture is smooth. Bring to a simmer, stirring frequently, until the sauce thickens enough to coat the back of a spoon, about 3-5 minutes. Remove from heat and stir in the thyme, nutmeg, 3/4 cup of the Gruyère cheese, and all of the Parmesan cheese until melted and smooth.
Gently fold the roasted mushroom slices into the cream sauce until well combined. Transfer the mixture to a 2-quart baking dish and sprinkle the remaining 1/4 cup of Gruyère cheese evenly over the top.
Bake at 350°F (175°C) for 20-25 minutes, or until the cheese is golden brown and the sauce is bubbly around the edges. Let the dish rest for 5-10 minutes before serving to allow the sauce to set.