You can not force the President to get a mental health examination when they don't want to.
But according to the 25th amendment of the constitution, the Vice President and at least half of the other cabinet members or half of Congress can declare the President unfit for duty. In that case the Vice President takes over until the President has recovered. They don't necessarily need a diagnosis by a medical professional to do this. Their judgment alone is sufficient here:
Section 4. Whenever the Vice President and a majority of either the principal officers of the executive departments or of such other body as Congress may by law provide, transmit to the President pro tempore of the Senate and the Speaker of the House of Representatives their written declaration that the President is unable to discharge the powers and duties of his office, the Vice President shall immediately assume the powers and duties of the office as Acting President.
If they would take such a drastic step, the POTUS would have to convince them that they are fit for duty. The most obvious method of doing that would be to get examined by a medical professional and show their expert opinion to the VP, Cabinet and Congress.