I am surprised that this question never received an answer, though it did receive useful comments. My view is that a claim like "Theorem 1 in paper B is wrong" is a claim, just like any other in paper A, and it's part of the job of the referee to check claims. So, I think that, as the referee, you have to decide whether or not this claim should remain in the paper, and that decision should be based on whether or not the claim is correct. If, indeed, paper B has an error and no erratum resolving it, then it's a real service of paper A to point it out and supply a correct proof. On the other hand, if there's no mistake in paper B, then by allowing this claim in paper A, you're allowing an error to get into the published literature.
Regarding "doubling the referee effort," consider that not all claims receive an equal amount of justification in paper A, and not all require an equal amount of effort to check. For example, paper A might have a lemma whose proof is left to the reader. As the referee, you'd want to check that you think the lemma is correct, and if you can't (or can't do so within the time you've allotted for refereeing), then you would ask in the referee report for more details. Do the same with this claim. If, when you read that proof in paper B, the error is obvious, then you've verified the claim. If you can't find the error in paper B, then it would be entirely appropriate to ask author A to supply more detail backing up their claim. This course of action was suggested by the first comment, but the third comment makes it clear the OP wanted more. Odds are that the error is subtle if the authors and referees of B missed it, so having A put more details about the error would help future readers. When in doubt, it's always wise to ask yourself what would help the reader? If there is a subtle error out there, having A devote more discussion to it will definitely help future readers.
A second guiding question is: what would help the author? It sometimes happens, when you referee a paper, that you find a mistake but the author is convinced there is not a mistake. A good referee will help the author realize their error. Likewise, perhaps the author is convinced that there's an error in paper B but you don't think there is. Again, helping the author figure this out will make them a better mathematician and will improve paper A that you've been asked to referee. Relatedly, it could be that there is a mistake in B but it's a very minor mistake, like B forgot to include a case. It would be appropriate for you, as the referee, to make suggestions (or even to insist) regarding A's wording (e.g., ask A to change it from "there is a mistake" to "Incidentally the case ... is missing from B, but is easily resolved"). When you do this, you can help prevent A from saying something stupid (e.g., acting like a minor mistake is a huge deal), you can help A navigate the politics of the situation (an aspect pointed out in Christian's comment), and you can improve A's paper and the experience of its readers, in seeing how best to handle a situation like this.
I don't think it's necessary to get B involved, though you could suggest to A that they alert B to the error (or that A should ask B for clarification if the proof is unclear). If you are concerned that author B is especially prickly and might make a problem with A or with the editor, you can alert the editor to the claim A is making and ask the editor's advice. Don't assume the editor will read A's paper or your referee report in full.
Lastly, it might be appropriate to think about power dynamics. If author A is junior and author B is senior, it would be good to help A find the right phrasing to navigate pointing out this error in a way that won't cause a backlash and hurt A's career. Or, if A is senior and B is junior, then maybe the language of how the error is pointed out could be softened. I think it's safe to assume that no professional mathematician wants to make a mistake, or to have one pointed out publicly, so in general it's probably wise to err on the side of softer language in cases like this. Let's all try to make math a little bit more welcoming, encouraging, and friendly.