Heat the oven to 350°F and grease a 9-by-13-inch baking dish with 1 tbsp of the butter.
Wrap the thawed hash browns in a clean towel and squeeze firmly until they no longer drip.
Melt the remaining 3 tbsp butter in a saucepan over medium heat and cook the onion until translucent, about 5 minutes.
Stir in the flour and cook for 1 minute, then whisk in the milk and simmer until the sauce coats a spoon, 3 to 4 minutes.
Remove the pan from the heat and stir in the sour cream, salt, pepper and 1 1/2 cups cheddar until mostly smooth.
Fold the sauce through the potatoes, spread the mixture evenly in the dish and scatter the remaining 1/2 cup cheddar over the top.
Bake until bubbling in the center and deeply browned at the edges, 45 to 50 minutes; rest for 10 minutes before serving.