Chief Justice Nisar made the remarks when Musharraf's lawyer told the three-judge bench that his client "respects the court" but was unable to return due to his medical condition and reservations over the provision of security, Dawn newspaper reported.
Musharraf, 75, who has been living in Dubai since 2016, is facing the high-profile treason case for suspending the Constitution in 2007. The former military ruler left for Dubai in March 2016 for medical treatment and has not returned since.
His lawyer told the court that there were no charges against the former president in the Lal Masjid operation case and demanded to know what the case against his client was, the paper reported.
He may not face any charges in the Lal Masjid case, but he is facing a treason case for which he must appear in court, replied Chief Justice Nisar.
If Musharraf returns voluntarily, he may be able to do so respectably otherwise he may be compelled to return under circumstances which are not "graceful", the top judge warned.
"The commando who used to describe himself as a 'courageous commando' should today display that courage," the top judge was quoted as saying by the paper.
"Why is the courageous commando not returning?" he asked.
"I told you before that if he returns, he will be provided security," the top judge said. He also advised that the former dictator should get medical treatment in Pakistan, the paper said.
"I am giving you this assurance. It is the assurance of the highest court in the country," Chief Justice Nisar said and added that: "As long as (Musharraf) is alive, it is his duty to appear before the court."
He further said that it was not acceptable for a citizen to leave the country and not return while a case against them is underway in courts.
The chief justice also promised that the former military ruler would not be arrested upon his return, and that whatever the outcome of the cases, it would be strictly in line with the law.
The court ordered Musharraf's lawyer to submit his medical report within a week and adjourned the hearing until October 11.
Last week, Muhammad Amjad, a leader of the All Pakistan Muslim League (APML) - a political party floated by Musharraf in 2010 -- had said that the former president was "growing weaker rapidly" due to an unspecified illness and, therefore, could not return to Pakistan.
The former Army chief has been declared an absconder due to his persistent failure to appear before a special trial court set up to try him in the case.
Last month, Pakistan's Supreme Court assured Musharraf that high-level security will be provided to him if he returns to the country to face the trial in the treason case.
The former president was indicted in March 2014 on treason charges for suspending the Constitution and imposing emergency which led to the confinement of a number of superior court judges in their houses and sacking of over 100 judges.
A conviction for high-profile treason carries the death penalty or life imprisonment.
Musharraf, who ruled Pakistan from 1999 to 2008, has been declared a fugitive in the Benazir Bhutto murder case and Red Mosque cleric killing case.