The word Mafia became known throughout Italy for the first time in 1863, when a Sicilian writer, Giuseppe Rizzotto [sic--according to Hess, Rizzotti e Mosca, 2], wrote a play entitled "I Mafiusi di La Vicaria" which went through 2,000 performances, over a period of 23 years, of which 34 in the Italian language, in Rome alone, in 1884.
According to Gaetano Mosca, the word mafia cannot be found in any Sicilian dictionary before 1868, when it was entered as a neologism in Traina's "Sicilian-Italian Dictionary."In another dictionary, Mortillaro's, published in 1878, the word is said to be of Piedmontese origin and to be synonymous with camorra. However, this is not correct. The adjective mafiusu (mafioso, in Italian) has been common in Sicily for at least two hundred years.
http://fiemafia.blogspot.com/2009/09/history-of-mafia.html
There are several theories about the origin of the term "Mafia" (sometimes spelled "Maffia" in early texts). The Sicilian adjective mafiusu may derive from the slang Arabic mahyas, meaning "aggressive boasting, bragging", or marfud meaning "rejected". Roughly translated, it means "swagger", but can also be translated as "boldness, bravado". In reference to a man, mafiusu in 19th century Sicily was ambiguous, signifying a bully, arrogant but also fearless, enterprising, and proud, according to scholar Diego Gambetta. In reference to a woman, however, the adjective "mafiusa" means beautiful and attractive.
The public's association of the word with the criminal secret society was perhaps inspired by the 1863 play "I mafiusi di la Vicaria" ("The Mafiosi of the Vicaria") by Giuseppe Rizzotto and Gaetano Mosca. The words Mafia and mafiusi are never mentioned in the play; they were probably put in the title to add a local flair. The play is about a Palermo prison gang with traits similar to the Mafia: a boss, an initiation ritual, and talk of "umirtà " (omertà or code of silence) and "pizzu" (a codeword for extortion money). The play had great success throughout Italy. Soon after, the use of the term "mafia" began appearing in the Italian state's early reports on the phenomenon. The word made its first official appearance in 1865 in a report by the prefect of Palermo, Filippo Antonio Gualterio.
https://en.wikipedia.org/wiki/Mafia#Etymology