All perfect praise be to Allah, The Lord of the worlds. I testify that there is none worthy of worship except Allah and that Muhammad, sallallahu ‘alayhi wa sallam, is His slave and Messenger.
It is impermissible for men to wear necklaces or chains regardless of whether they bear these blessed names or not because wearing them constitutes imitating women. Wearing necklaces, rings, and earrings is the adornment of women. Ibn ‘Abbaas, may Allah be pleased with him, said, "The Messenger of Allah, sallallahu ‘alayhi wa sallam, cursed the men who imitate women and the women who imitate men..." [Al-Bukhaari]
The prohibition is further emphasized if such chains and necklaces are made of gold because it is prohibited for men to wear gold.
As for women, it is allowable for them to wear gold chains or otherwise, and there is no harm in inscribing the name of the Prophet, sallallahu ‘alayhi wa sallam, or the names of other Prophets and Messengers, may Allah exalt their mention, on such chain as long as the intention is not to wear them as amulets (for protection). It was reported that some of the righteous predecessors from among the Companions and their followers (the Taabi'is) inscribed their rings with Thikr (expressions of remembrance of Allah). Therefore, the majority of scholars held that it is allowed to inscribe Thikr on rings. Al-Haafith Ibn Hajar wrote:
"Ibn Abu Shaybah narrated that Huthayfah and Abu ‘Ubaydah wore rings bearing the phrase 'Alhamdulillah' (praise be to Allah). ‘Ali wore a ring bearing the Divine Names 'Allah Al-Malik' (Allah The Sovereign). Ibraaheem An-Nakha‘i wore a ring bearing the phrase 'Billah' (with the help of Allah), and Masrooq wore a ring bearing the phrase 'Bismillah' (In the Name of Allah). Abu Ja‘far Al-Baaqir wore a ring bearing the phrase 'Al-‘Izzah lillah' (Might belongs to Allah). It has been reported on the authority of Al-Hasan and Al-Husayn that there is no harm to engrave phrases of Thikr on one's ring. An-Nawawi said that this was the view held by the majority of scholars..." [Fat-h Al-Baari]
In any case, the woman who wears a necklace or any ornament bearing such blessed names should be cautious not to show disrespect to such blessed names; it is disliked for her to enter the bathroom wearing them. Khash-shaaf Al-Qinaa‘ reads, "It is disliked to enter the bathroom carrying something bearing the name of Allah..." The author of Al-Mubdi‘ said, "The same applies to the name of the Messenger as well."
Allah knows best.