Does Caterpillar Fungus contain a real caterpillar?

The quick answer to this question is yes. Caterpillar Fungus does contain a part of the caterpillar body. Caterpillar fungus is composed of stromata of the entomopathogenic fungus, and the larva of ghost moths or dead caterpillar used as parasites.
Health benefits
Caterpillar fungus has been used as as a traditional Chinese medicine, especially in Tibet. The earliest record of O. sinensis can be traced back to the fifteenth-century, where it was mentioned in the Tibetan medical text as “yartsa gunbu” by Nyamnyi Dorje, a Tibetan physician. He wrote “An Ocean of Aphrodisiacal Qualities”, stating that the caterpillar fungus could be used as a sexual tonic. Until 1694, the first mention of caterpillar fungus as “Dong Chong Xia Cao” was stated in Wang Ang’s compendium of material medical, Ben Cao Bei Yao.4 It was expected to “treat lung and kidney diseases, to perform hemostatic function, to reduce phlegm production, and to relieve cough”.
The indigenous people in Mt. Laojunshan and Tibetan people also believed the herb to have the ability of improving eye sights, curing calcium deficiency, indigestion, diabetes and strengthening the immune system. The Tibetans in Shangri-La County had been using caterpillar fugus to treat hypertension, rheumatism, and speeding up labor parturition.
The caterpillar fungus must be dried under the shade. It is believed that drying in the sun would diminish the quality and potency of the product. A complete drying is necessary as larvae of other insects or molds might survive and destroy the caterpillar fungus.
Consumption
Caterpillar fungus may be consumed in many different ways. Normally in India and China, it was cooked with chicken or duck and consumed as a medicinal food. Some people simply chew the herb with water or grain alcohol or eating it raw. Some make tea by boiling the O. sinensis in water and steep it for one day. The grinded O. sinensis could be mixed with eggs and steamed before consumption. Tibetan people mix grinded O. sinensis with butter and make butter tea. In the west, most Cordyceps sinensis consumed are grounded mycelium made into pills. Instead of the harvested natural product, the mycelium are the hyphae (network of fungal strands) grown artificially on the grains. Nonetheless, caterpillar fungus was also marked as a status symbol or prestigious gift.
References:
Yang FQ, Feng K, Zhao J, Li SP. Analysis of sterols and fatty acids in natural and cultured Cordyceps by one-step derivatization followed with gas chromatography–mass spectrometry. Journal of Pharmaceutical and Biomedical Analysis. 2009;49(5):1172-1178. doi:10.1016/j.jpba.2009.02.025
Winkler D. Yartsa gunbu (cordyceps sinensis) and the fungal commodification of Tibet’s rural economy. Economic Botany. 2008;62(3):291-305. doi:10.1007/s12231-008-9038-3
Winkler D. Caterpillar Fungus (Ophiocordyceps sinensis) Production and Sustainability on the Tibetan Plateau and in the Himalayas. Asian Medicine. 2009;5:291-316.
Chen J, Lee S, Cao Y, Peng Y, Winkler D, Yang D. Ethnomycological Use of Medicinal Chinese Caterpillar Fungus, Ophiocordyceps sinensis (Berk.) G. H. Sung et al. (Ascomycetes) in Northern Yunnan Province, SW China. International Journal of Medicinal Mushrooms. 2010; 12:427-434.