Preheat the oven to 375 degrees F. Place the squash on a baking sheet skin side down. Top with the olive oil, thyme, sage, red pepper flake, if using, and season with salt. Flip the squash over and season the skin side with salt pepper and the remaining olive oil. Add the garlic cloves to the sheet pan and place into the oven, bake until a knife inserted into the center of the squash comes out with little to no resistance about 25 to 35 minutes. Remove from the oven and cool.
Meanwhile, bring a large pot of water to a boil and season liberally with salt. Cook the pasta one to two minutes less than the package calls for al dente. Drain the pasta and reserve 1/2 to one cup of the water.
Use a spoon to scoop one half of the squash flesh into a blender along with the herbs and roasted garlic cloves removed from the skins. Add in half of the cream, pasta water, and ricotta. Season with salt and pepper and the nutmeg and blend until smooth and creamy.
Place the mixture into a bowl and repeat with the remaining squash, cream, pasta water, and ricotta.
Toss the pasta with the squash mixture. Place half of the pasta mixture into the buttered baking dish and layer half of the cheese over the top. Repeat with the remaining layer of pasta and cheese. Bake for about 15 minutes until golden brown and bubbly. Let rest for ten minutes before serving. Top with additional herbs if desired.