Taking my research idea outside my paid job I'm doing a (paid, contractual) remote research internship with a research institute in Germany. My job is to come up with novel ideas, write papers for technical conferences and try to publish them. My supervisor here is A.

There is another individual B from a different institute in the USA, who has expressed interest in a research collaboration with me. However, this arrangement is informal, wherein he would provide his comments on my ideas and help me publish them. He would also be one of the authors of the resulting paper.

Now during my regular work with A, I had proposed a couple of ideas to him: he liked one but said the other was not promising. It so happens that I do think that the second idea is promising, perhaps even more so than the first idea that he liked.

So my question is, is it legal and ethical for me to take my second idea to B and ask him for help in getting it published? Before I start this endeavour, should I perhaps ask A in unequivocal terms whether I can take my idea elsewhere? If A has no use for the idea he shouldn't have a problem in allowing me to do so (I hope, but I'm not sure). Is this a reasonable question to ask a supervisor?

I feel like this is a grey area but I also think that the idea I have is a good one, and I don't want to waste it (by getting it published before someone else comes up with a similar idea).
If the idea is valuable you should talk to an attorney. 

You want to avoid encumbrances.  If there is some small chance that if the idea hits it big, A can claim some ownership, the thing to do is to get a letter stating that A waives all claims around this idea.

There are also time-sensitive issues surrounding your situation from the perspective of protecting IP.  In your conversations with A and B, you might have "disclosed", starting a clock starting for patent procedures.

Again, if it's important, this is what lawyers are for.