Preheat oven to 375ºF. Coat a baking sheet with cooking spray. Coat a 2 1/2- to 3-quart baking dish with cooking spray.
Place squash on prepared baking sheet; roast until tender, about 20 to 30 minutes. Place in a large bowl and mash.
Meanwhile, bring a large pot of salted water to a boil. After squash has been roasting for about 10 minutes, cook pasta according to package directions; drain and return to pot.
In a medium saucepan, whisk together milk, flour, garlic, salt and pepper. Bring to a boil over medium-high heat, whisking frequently; reduce heat to low and simmer, stirring often, until thickened, about 2 minutes. Remove from heat; stir in mashed squash and 2 1/2 teaspoons of thyme. Add sauce to pasta; toss to mix and coat.
Transfer pasta mixture to prepared baking dish; dot with spoonfuls of ricotta and then sprinkle with Parmesan and walnuts. Bake until top is lightly browned in a few spots, about 15 to 20 minutes; remove from oven and sprinkle with remaining 1/2 teaspoon of thyme.