Praise be to Allah.
It is not permissible to write “Ya Muhammad” on the necklace.
Firstly: because this wording is akin to du’aa’, and it is well known that it is not permissible for anyone to call upon anyone other than Allaah, because Allaah says (interpretation of the meaning):
“And the mosques are for Allaah (Alone), so invoke not anyone along with Allaah”
“And who is more astray than one who calls on (invokes) besides Allaah, such as will not answer him till the Day of Resurrection, and who are (even) unaware of their calls (invocations) to them?”
And the Prophet (peace and blessings of Allaah be upon him) said to Ibn ‘Abbaas (may Allaah be pleased with him): “If you ask, then ask of Allaah, and if you seek help, then seek the help of Allaah.” Narrated by al-Tirmidhi (2516); classed as saheeh by al-Albaani in Saheeh Sunan al-Tirmidhi.
Secondly: Some of the ignorant wear these necklaces or hang them in their cars in the belief that they bring some benefit and ward off some harm, and they seek blessing from it, thereby falling into shirk, because the Prophet (peace and blessings of Allaah be upon him) told us that wearing amulets is shirk. As narrated by Abu Dawood (3883) and classed as saheeh by al-Albaani in Saheeh Abi Dawood.
It is well known that Islam came to block every route that may lead to shirk.
Moreover the rights that the Prophet (peace and blessings of Allaah be upon him) has over us are many, and they cannot be fulfilled merely by putting his name on necklaces, medallions and frames.
The rights of the Prophet (peace and blessings of Allaah be upon him) over us are that we should believe in him and in what he told us, obey his commands, heed his prohibitions, submit to his rulings and accept them, follow his Sunnah, send blessings upon him ( (peace and blessings of Allaah be upon him)), defend him and refute those who criticize him and disbelieve in him. May Allaah send blessings and peace upon him. And Allaah knows best.