Preheat the oven to 375°F (190°C). Place the cauliflower florets on a sheet pan. Drizzle with half of the olive oil and sprinkle with half of the salt and half of the pepper. Toss well, arrange in one layer, then bake, tossing halfway through, until the cauliflower is tender and starts to brown, about 25 minutes.
Meanwhile, heat a medium saucepan over medium heat. Add the remaining olive oil and one-fourth of the butter. When the butter has melted, add the onion and cook until they’re softened and translucent, 2 to 3 minutes. Stir in the heavy cream and sour cream, then continue stirring while the mixture bubbles and thickens to the consistency of a milkshake, 2 to 3 minutes. Stir in the garlic powder and the remaining salt and pepper, half of the Gruyere, and half of the Parmesan cheese. Remove the cheese sauce from the heat and set aside.
Grease a small (2-quart) casserole dish with one-third of the remaining butter. Spread the roasted cauliflower into the prepared dish, then pour the cheese sauce over the cauliflower.
Make the topping: In a medium bowl, combine the remaining Gruyere and Parmesan cheese and the almonds and green onions. Melt the remaining butter and pour it over the cheese-almond mixture, then toss to combine. Evenly distribute the topping over the cauliflower.
Cover the gratin with aluminum foil and bake for 15 minutes. Remove and uncover the gratin, turn on the broiler and set a rack about 5 to 6 inches from the heat source, then broil the gratin until golden and bubbling, 1 to 2 minutes. Remove and serve.