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.
Eclectic gardening style, drawing from 45 years of interest and experience. Mostly plant in raised beds and containers primarily using intensive gardening techniques.