Arrange a rack in the middle of the oven and heat the oven to 350°F. Coat a 9x9-inch baking dish with butter.
Trim and slice 2 pounds yellow squash into ¼-inch thick rounds (about 7 cups). Dice 1 medium sweet onion (about 1 ½ cups). Grate 8 ounces sharp cheddar cheese on the large holes of a box grater (about 2 cups).
Melt 2 tablespoons of the unsalted butter in a 12-inch or larger skillet over medium heat. Add the squash, onion, ¾ teaspoon kosher salt, and ½ teaspoon black pepper. The skillet will be quite full. Cook, stirring occasionally, until tender and just beginning to brown, about 10 minutes.
Transfer the squash and onions to a colander set over a bowl or placed in the sink; reserve the skillet. Set aside to drain for 5 minutes.
Place 2 large eggs, ¼ cup mayonnaise, ¼ cup sour cream or yogurt, ¼ teaspoon cayenne pepper, and half of the cheese in a large bowl and whisk to combine.
Transfer the squash and onions into the egg mixture. Stir to coat the vegetables in the sauce. Transfer to the baking dish and spread into an even layer. Sprinkle with the remaining 1 cup cheese.
Use your hands to crush butter crackers into coarse crumbs (about 1 cup). Evenly sprinkle the cracker crumbs over the casserole.
Bake until browned and the edges bubble, 25 to 30 minutes. Turn broiler on high and cook another 2 minutes to brown top. Remove from oven and let cool for 5 minutes before serving.