This is kind of like asking whether it is ethical to copy someone else’s technology. As we know, there are some weird things going on in the area of patenting of biological technologies. Who owns our DNA? How can a company take a part of our DNA and patent it?
In any case, if the aliens paid for the privilege, then it seems to me it would be ethical. However, if genetic material is just lying around for the taking, it seems to me that it would not be that unethical to take a sample and reverse engineer it. Humans are reverse engineering things all the time. That’s how much of the rest of the world makes advances with technology.
In any case, to answer the question, I think that if they just took the DNA, it would be of dubious ethicality. However, if they paid licensing fees, there would be no problem. Who they would pay licensing fess to is another question. It does seem to me that if they are capable of traversing interstellar space, they would probably have a lot to trade for the DNA.
I’m not sure we’d want them to have the DNA. They might design viruses that could kill us all off, so they could take over the planet. Unfortunately, I don’t see how we could prevent them from getting our DNA. Even if we keep them from landing on the planet, surely some of our DNA is floating around in space—perhaps attached to pieces of space junk that we’ve lost track of.
Anyway, we don’t really need to think about aliens with respect to this question. It’s a live issue amongst humans. Who owns our DNA?