Which chemical formula reflects the diagram?

The correctly written formula is D. C6H12O6.
C6H12O6 is the formula of several isomers including hexoses.
Hexoses are a family of monosaccharides with 6 carbon atoms. They all have the same formula C6H12O6. They all have a carbonyl group:
* an aldehyde function in position 1 (aldohexoses)
* a ketone function in position 2 (mainly), 3, 4 or 5 (ketohexoses or dihydroxyketone).
There is hemiacetalisation between the carbonyl function and an OH (for example, between the carbon 1 and 5 of the glucose)