The answer differs per sector, and the dividing line is always the same: do the rules drive the work, or does the audience? In the first case a specialist pays off, in the second it can be briefed.
Pharma: yes, a specialist
Here regulation determines what may be said, to whom, and with what approval. A generalist learns that at your expense and at your risk. Ask which approval procedures they know, and who does the medical and regulatory check on their side.
Public sector: yes, for a different reason
It is not the creative that differs but the procedure. Public assignments run through tenders with formal criteria, deadlines and award rules. An agency that knows that procedure does not lose a bid on a technicality, and that happens more often than you would think. Ask which framework agreements they are on.
Retail: usually not
What you buy here is pace and volume: many executions, short lead times, strong production. That is a matter of organisation, not sector knowledge. Ask about their production capacity and how they get through a week with fifty amendments, not about retail cases.
B2B: not the industry, the audience
The real question is whether the agency can write and think for a technical or professional buyer with a long decision path and several decision makers. That skill travels: whoever can do it for machinery can do it for software. Ask for work on complex purchases, whatever the sector.
What holds in all four cases
Sector specialists almost by definition also serve your competitors. Ask which ones, and how they organise separation. And weigh that an agency knowing your market inside out also applies that market's conventions inside out. If you want to stand out, that is a drawback.
On the factsheets you can browse by sector and cross sector with expertise, so you get "digital agencies with pharma experience" instead of one or the other.
See also: which agency fits your sector and should I pitch or award directly.