Preheat your oven to 400°F and lightly grease a 9x13-inch baking dish with butter or nonstick spray.
Toss the trimmed green beans, sliced mushrooms, and sliced shallots with the olive oil, kosher salt, and black pepper on a large rimmed baking sheet. Spread into a single layer and roast for 20 minutes, or until the vegetables are tender and slightly caramelized at the edges.
While the vegetables roast, melt the butter in a medium saucepan over medium heat. Whisk in the flour and cook for 1 minute until the mixture is smooth and bubbly to form a roux.
Gradually whisk in the warmed milk until the sauce is completely smooth and begins to thicken, which should take about 3-4 minutes. Remove the saucepan from the heat and stir in the shredded Gruyère cheese until it is fully melted and the sauce is creamy.
Transfer the roasted vegetables to the prepared baking dish and pour the cheese sauce evenly over the top. Sprinkle with the grated Parmesan cheese and panko bread crumbs.
Bake for 15-20 minutes, or until the topping is golden brown and the sauce is bubbly around the edges. Let the bake rest for 5 minutes before serving to allow the sauce to set.