I've never tried, but these plants have pretty big root systems, so would be surprised if they would like the confines of a container, unless it is a very large one. There are dwarf varieties available, and IMO they would be worth a try. Here is a link to one dwarf variety of broccoli.
I think I read somewhere that then can be grown 1 to each 12" pot, or maybe it was one to each 5 gal bucket (with drainage holes). So I guess the answer is "not impossible" but provide lots of room. I imagine there are varieties that are more suited to container culture. You might also look for smaller headed varieties.
I tried broccoli in 5 gallon buckets last year and only got very small heads on them.
HOWEVER, last year we went from a cold winter to a HOT summer in (what seemed like) a week. I live in middle Arizona. Also, I have to admit, I didn't pay much attention to the broccoli at all.
This year I have about 6 plants in 5 gallon buckets, and am going to try to nurture them significantly more, and see what happens.
I'm going to go relatively heavy on fertilizer this year. A 15-15-15 mix. I didn't fertilize at all last year.
I'm also going to add a nice inch of mulch to try to keep the roots cool this year. I really think the sudden high heat is what sabotaged my efforts last year.