1Preheat oven to 350 degrees F (175 degrees C). Spray a 9x13-inch casserole dish with cooking spray.
2Bring a large pot of salted water to a boil; cook squash in the boiling water until very tender, 10 to 15 minutes. Drain and transfer squash to a large bowl; mash until evenly smooth.
3Heat butter in a skillet over medium heat; cook and stir onion in the melted butter until tender, 5 to 10 minutes. Mix onion, cream of mushroom soup, Cheddar cheese, bread crumbs, milk, mayonnaise, sugar, eggs, salt, and pepper into mashed squash. Spread mixture evenly into the prepared casserole dish.
4Bake in the preheated oven until bubbling and edges are lightly browned, 45 minutes to 1 hour.
Footnotes
Cook's Note:
Casserole can be covered and refrigerated several hours or overnight before baking.