Preheat the oven to 400°F (200°C). Line a baking sheet with parchment paper.
Toss the butternut squash with about half of the olive oil, a pinch of salt, and black pepper. Spread it into a single layer and roast for 18 to 22 minutes, until just tender and lightly caramelized around the edges. Don’t roast it until completely soft because it will continue cooking in the pie.
Meanwhile, fit the pie crust into a 9-inch pie plate. Prick the bottom lightly with a fork, line with parchment paper, and fill with pie weights or dried beans.
Blind-bake the crust for 12 minutes. Carefully remove the parchment and weights and bake for another 3 to 5 minutes, until the bottom looks dry but isn’t deeply browned. Remove from the oven.
Reduce the oven temperature to 350°F (175°C).
Heat the remaining olive oil in a skillet over medium heat. Add the mushrooms and cook for about 4 to 5 minutes, until they release their moisture and begin to brown.
Add the shallot and ham and cook for another 2 to 3 minutes, until the shallot softens and the ham develops a little color around the edges.
Add the garlic and rosemary and cook for about 30 seconds, just until fragrant. Remove from the heat.
In a medium bowl, whisk together the eggs, milk, remaining salt, black pepper, and ¾ cup Parmesan until combined.
Arrange the roasted butternut squash and ham-mushroom mixture evenly inside the partially baked crust.
Slowly pour the egg mixture over the filling, allowing it to settle between the vegetables. Sprinkle the remaining ¼ cup Parmesan over the top.
Bake for 35 to 45 minutes, until the edges are set and lightly golden and the center has only a slight jiggle.
Let the pie rest for 15 to 20 minutes before slicing. Finish with fresh rosemary, additional Parmesan, and black pepper if desired.