In the movie Captain Marvel, the main antagonists (at least for half the movie), the shape-shifting Skrulls, can change their appearance to perfectly match any humanoid creature, down to DNA. Scientifically, I would label this as just conscious and very fast evolution, but they also replicate the DNA of the creature perfectly, without further study of it. Can this be achieved, at least in a lab?
You can deduce certain things about a person from their physical appearance, hair colour, skin colour, eye colour - will all give you clues to certain genetic markers that they will carry.
You can perform every physiometric and psychometric test on a person at our disposal, and make a number of deductions.
You can have the complete paternal and maternal DNA profile on record including the mitochondrial DNA.
None of this gives any certainty as to the genotype of the individual/offspring.
The phenotype (expressed genes) is not even entirely dependant on the genotype (total genes - used or not), because of epigenetics (some genes have a chemical group attached which prevents them from working and thus hides them from observation).
This is much less than half the story: Between 85% and 92% of DNA is non coding. That is, it's junk, it doesn't do anything and therefore has no observable effect that could be used to infer it's presence - but it's still there measurable to a DNA test.
I suddenly realised that I answered the question for humans. The question asks about humanoids. It's incumbent on the OP (the author of the world in which a story takes place) to decide the rules there. There their humanoids may have a different genetic history, may have had the junk DNA removed to streamline the code. Genes and epigenetics might be standardised, a whole society could be of a limited number of genotypes - all clones - all down to the author's choice.
I don't remember which book, but one of Richard Dawkins' books makes a point that is relevant to this question:
Often DNA is described as the blueprint for an organism. However, that's a bad analogy: DNA is much better described as the recipe for an organism. By looking at a completed building, you can probably re-draw the original blueprints with reasonable accuracy. But by looking at a completed meal, you will have a lot more trouble accurately listing back out the original quantity of every ingredient and the steps to transform them into the finished product.
As a shape-shifter, a Skrull could certainly replicate the outer appearance and characteristics of what they see in another organism, but replicating the DNA based on observation would be out of the question. If for no other reason than multiple different "recipes" could, conceivably, result in the same result. How would the Skrull pick the right one just by looking at a person? (Although looking back at your question, I realize you didn't limit to just visual macro observation, but I haven't seen the movies so I don't know how much observation the Skrull need before shape-shifting.)