It would be quite a stretch to consider interview questions as property. If re-using interview questions are unethical, then most companies are unethical. After all, haven't you seen or read interview advice that lists a lot of example questions or common questions?
Understandably, this situation isn't quite the same. I assume this question is creative and unique, but so was every other interview question at some time.
As long as you're not publishing the question and certainly not disclosing that Company A uses that question, I would say that you're being reasonably ethical. As long as candidates of Company A aren't aware of the question being associated with that company, they can't really take advantage of it.
So, really, there's no way to hurt Company A by your actions unless you are doing so deliberately.
However, this also applies to Company B.
You must accept that interview questions are not secrets. In a few years, it's possible that the question we are talking about is on the list of "Top 10 interview questions to memorize!".
Both Company A and B should have interviewing mechanisms that prevent applicants from memorizing your interview. These mechanisms can't exist if we are convinced that our questions are secrets. I mean, you went from Company A to Company B. What's stopping another person from doing the same. If they do, they will already be prepared for this magical question when they come to you!
The only time a question is a secret is before it's asked.