The Sanskrit is just a cognate of the loanword. [noted -ed] This is more plausibly some Iranian word (there were many Iranian languages to choose from, not all well-recorded), c.f. Sogdian margārt, modern Persian marvārīd. The old Persian etymologies given below seem dubious, and do not explain the Sanskrit cognate which would be at least as old as Old Persian. Note that the Syriac plural marɡɑnjɑthɑ (descended from Aramaic, the lingua-franca of much of the Persian empire) resembles the Sogdian (an Iranian language from Central Asia).
Margaret is not borrowed from Sanskrit, how and why could it have been? It has a known etymology in Old Iranian margha-writha, meaning Pearl. Naturally, since the Persian Gulf was the main source of Pearls up to quite recent times, it would make sense that the name was in an Iranian language too. The Old Iranian itself probably came from margha- "bird" (c.f. Persian morgh) and -writh which is a suffix denoting similarity, together meaning "bird-like" which most likely referred to the shape of the shell, being similar to wings of a bird.
"Ultimately from Greek margarîtçs, 'pearl,' probably of Iranian origin."From The American Heritage Dictionary, 4th ed., under the entry for "margarite": The Iranian word was marjan, originally meaning 'pearl,' though the modern word means 'coral'. From A. Mingana, "On the Meaning of the Persian Word for Pearl and Coral." Man, Vol. 25, Mar., 1925 (Mar., 1925), pp. 41-42: Marjan is also a feminine Iranian name in its own right.
The Greek word ìáñãáñéôçò meaning "pearl" itself is a borrowing from the Old Persian marga-reta "bird like", originally refering to the shell which contained the pearl, which resembles the wings of a bird folded over each other! Marga is "bird" (c.f. New Persian morgh "bird") and reta was a relative suffix.See: Ferdinand Justi "Iranisches Namenbuch" and C. Bartholomae "Altiranisches Woerterbuch".
The only information I could find for "marga" was that it was an Indo-Iranian word meaning 'meadow' and a Sanskrit word meaning 'path.' (ie. The margas of Indian philosophy) Don't know if that's useful or not, but there you are. I'd love it if the derivation came from 'bird-like' but I couldn't find any other info about that.