Can you observe, hypothesize and test in-character in D&D? Probably. Whether it works depends a little on edition and how the DM runs. A DM running highly simulationist RAW 3e, for instance, will probably give you repeatable enough results to perform valid experiments. You'd be able to uncoverthe existence of hit points, skill checks, and quantify bonuses, and the like. You'd be able to 'prove' the superiority of one weapon over another, reverse-engineer character class and level from population survey data and so forth.
OTOH, a DM running 5e in full 'empowered' mode would drive the would-be scientist crazy.