Preheat the oven to 375°F; position one of the oven racks in the center and place a large baking sheet on top. Lightly oil and line a 9- by 5-inch loaf pan with a sheet of parchment paper long enough to hang over the wide edges and fold up and over the top of the finished loaf. Set aside.
Make the polenta: In a large bowl, toss together the broccoli, ¼ cup olive oil, ½ teaspoon salt, the chile flakes, and garlic, then spread the mixture over the hot baking sheet in an even layer and roast until the broccoli is tender and slightly browned, about 15 minutes.
Remove the pan from the oven, then carefully transfer the broccoli to the bowl of a food processor and pulse just until it reaches a coarse, crumbly texture. (Do not purée.) Alternatively, hand chop the broccoli using a chef’s knife. Set aside.
In a medium pot over high heat, bring the chicken broth, butter, and ½ teaspoon salt to a rolling boil, then remove from the heat and set aside.
Set a large pot over medium-high heat. Add the polenta and cook, stirring continuously, until fragrant and toasty, about 2 minutes. Begin adding the hot broth to the polenta approximately 1 cup at a time, whisking until smooth after each addition. When all the liquid has been added, bring the polenta to a full boil, then turn the heat down to maintain a steady simmer and cook, whisking and scraping the bottom and the sides of the pot every 5 minutes, until the polenta is no longer al dente and the liquid is fully absorbed, 15–25 minutes. (The cook time will vary based on the brand of polenta, but the granules should feel soft to the bite; it will take some elbow grease to whisk at the end.)
Using a wooden spoon, fold the reserved broccoli and the grated pecorino into the polenta until fully incorporated, then spoon the mixture into the lined loaf tin. Set aside until cool enough to handle, then fold the overhanging parchment flaps over the surface of the loaf, pressing down to level. Refrigerate for at least 2 hours, or for up to 1 week.
When ready to serve, preheat the oven to broil (convection broil, if available). Position one of the oven racks in the center and place a large baking sheet on top.
Meanwhile, use the parchment paper to transfer the polenta from the loaf pan and onto a cutting board; cut crosswise into eighteen ½-inch-thick slices. When the oven is hot, add 2 tablespoons of the olive oil to the hot baking sheet; use a pastry brush to spread the oil around to coat the surface, then transfer the polenta slices to the sheet in a single layer. Brush the olive oil from the surface of the pan over the tops of the slices then broil until evenly golden brown, 15–20 minutes. Keep warm while you roast the mushrooms.
Cook the mushrooms: Turn the oven down to 425°F and place another large baking sheet inside. When the oven is hot, place the mushrooms on the baking sheet and drizzle with the remaining olive oil. Season generously with fine sea salt and bake until the mushrooms are crispy on the edges, about 15 minutes. Remove from the oven and set aside.
Arrange the polenta slices over a large platter. Top with the roasted mushrooms, season to taste with flaky sea salt and black pepper, and serve hot.