Set a steamer basket inside a saucepan and add water until it reaches just below the basket. Bring the water to a boil, add the cauliflower florets, cover, and steam until a fork slips in easily, about 5–7 minutes.
While the cauliflower steams, preheat the oven to 350°F (175°C) and grease a 9x9-inch baking dish with butter or cooking spray.
Melt the butter in a small saucepan over low heat. Add the chopped onion and cook, stirring occasionally, until softened and translucent, about 5 minutes.
Sprinkle the flour over the softened onion and cook, stirring constantly, until it begins to take on a light golden color, about 3–5 minutes. Gradually whisk in the milk until the mixture is smooth, then bring it up to a gentle simmer to thicken.
Remove the sauce from the heat and stir in half of the shredded Cheddar until it melts. Season the cheese sauce with a pinch of black pepper and a little nutmeg to taste.
Place the steamed cauliflower into the prepared baking dish, pour the cheese sauce evenly over the florets, then sprinkle the remaining Cheddar on top.
Bake until the casserole is bubbling and the top is golden-brown, about 25 minutes. Allow it to rest for a few minutes before serving.