Preheat oven to 350ºF. Lightly grease an 8x8-inch square or oval baking dish.
Heat 3 tablespoons of oil in a large skillet over medium heat. Add the shallots. Cook, stirring often, until just beginning to brown, about 5-7 minutes.
Sprinkle the flour over the shallots and stir well
Switch to a whisk, and add the milk to the skillet, whisking until smooth. Add the butternut puree and whisk again. Allow the sauce to cook over medium heat, whisking often, for 6-7 minutes, or until thickened.
Remove the sauce from the heat and stir in the Parmesan cheese, rosemary, and nutmeg. Season to taste with salt and pepper, then fold in the ziti. Transfer to the prepared baking dish and top with the shredded Gruyere.
Cover the baking dish with foil and place it in the oven. Bake for 10 minutes covered. Remove the foil and bake uncovered for an additional 10 minutes. If desired, place the dish under the broiler for a few minutes for a golden top. Sprinkle with a little more minced fresh rosemary and serve immediately.