Disclaimer: I am not a lawyer
Technically, as far as I understand it, it counts as an unlicensed trademark usage and so is illegal. However, in practical terms, you probably won’t get sued unless the owner feels that you’re damaging their brand.
For example, if the character is a brutal serial killer and the show really becomes famous, you might get a lawyer’s letter because the Batman association can be interpreted as “damaging”. Occasion visibility of logos that are not the focus of the show are probably not a big problem, but you should keep it to a minimum.
Another example: one of the characters in our show gets a job at a coffee shop, and one line of dialog calls it “lousy coffee”, and so we had to make up a fake coffee shop brand because of the disparaging nature of that line.