Preheat oven to 425°.
Using your hands or a pastry brush, grease the inside of a 2 quart baking dish with the butter (oval, round, rectangle or square will all work).
Add ⅓ of the squash on the bottom of the baking dish followed by a ⅓ of the onions. Season with salt, pepper, crushed red pepper flakes, nutmeg (if using) and a few marjoram leaves. Add ⅓ of the cheese and repeat until you’ve reached the top of the baking dish, ending with squash and onions.
Pour heavy cream over everything and top with remaining cheese.
Cover with foil and bake until squash is just tender, 20–25 minutes. Remove foil and continue to bake until cream has thickened and reduced and the top is browned and crispy, 40–45 minutes.
Remove from oven and scatter with a few more marjoram leaves and a pinch of red pepper flakes. Let cool slightly before eating.