Preheat the oven to 350°F (175°C). Lightly grease a 9x13-inch baking dish and set aside.
Melt 4 tablespoons of unsalted butter in a wide skillet over medium heat. Add the sliced onions, salt, black pepper, and sugar if using. Cook, stirring regularly, until the onions become soft and develop a light golden hue, about 15 minutes.
Take the skillet off the heat. Blend in the sour cream and beaten eggs, stirring until the mixture becomes uniform and creamy.
Stir in half of the shredded cheddar and all of the mozzarella, folding gently until evenly incorporated.
Transfer the prepared onion mixture into the greased baking dish, spreading it out evenly. Sprinkle the surface with the remaining cheddar cheese.
In a separate bowl, combine the crushed crackers with the melted butter. Distribute this mixture evenly over the top of the casserole.
Place the dish in the oven and bake uncovered for 30 to 35 minutes, or until the top is golden brown and the edges are bubbling.
Allow the casserole to rest for approximately 5 minutes before serving. Ideal alongside roasted poultry, smoked meats, or festive entrees.