Preheat the oven to 375°F (190°C) and grease a 9x13-inch baking dish.
Heat the olive oil in a large pan over medium heat. Add the onions and cook, stirring occasionally, until soft and golden brown, 12 to 15 minutes.
In a large bowl, combine the squash cubes, caramelized onions, sage, salt, and pepper.
Spread the mixture evenly in the baking dish.
Sprinkle the cheese evenly over the top, then the breadcrumbs if using.
Bake for 30 to 35 minutes, until the squash is fork-tender and the cheese is bubbly and golden. If the cheese browns before the squash is tender, cover loosely with foil.
Let the casserole rest for 5 to 10 minutes before serving.