Preheat oven to 375°. Evenly arrange half of sweet potatoes and shallot (including any uneven pieces) in a shallow 2 1/2- to 3-qt. baking dish. Combine chopped thyme, salt, and pepper in a small bowl, and gouda and 1 tbsp. flour in another bowl. Sprinkle sweet potatoes with half of thyme mixture and half of gouda mixture. Arrange remaining sweet potatoes in dish in overlapping rows. Scatter with remaining shallot and thyme mixture.
In a small bowl, whisk remaining 3 tbsp. flour with 1/4 cup cream until smooth. Whisk in remaining cream and the broth. Pour evenly over sweet potatoes and top with remaining gouda mixture.
Bake until gratin is bubbling and golden brown, 45 to 55 minutes, increasing the heat to 400° for the last 5 minutes or so. Let sit 10 minutes before serving. Set a thyme sprig on top and add more salt and pepper to taste.