As stated in the Le Parisien article mentioned in the BBC article you linked, a medical exam is simply something that a prosecutor must order as part of an investigation for the type of offense that Le Pen is being investigated for.
However, since the point of the medical exam is to provide proper prison care in the event of a conviction I'm sure there are few penalties(if any) for ignoring the order, and that challenging the order wouldn't be too difficult.
The section of the French legal code that requires this sort of order is Article 706-47-1. Translated from the original French:
Persons prosecuted for one of the offenses mentioned in article 706-47 must be subjected, before any judgment on the merits, to a medical report. The expert is questioned about the desirability of an order of care in the framework of a socio-judicial follow-up.
This expertise can be ordered at the stage of the investigation by the public prosecutor.
This expertise is communicated to the prison administration in the event of condemnation to a custodial sentence, in order to facilitate the medical and psychological monitoring in detention provided for by article 717-1.
Article 706-47 contains the various crimes that allow the above medical exam to be ordered, the relevant one for Le Pen being potentially sharing particularly violent content to minors:
Crimes of manufacture, transport, distribution or trade of violent or pornographic message likely to be seen or perceived by a minor
In this case, Le Pen posted various images of tortures/killings by ISIS which could easily have been seen by minors.