A mascot was a witch's charm long before it was a costumed bird on a sideline.
The word reached English through a hit operetta. Edmond Audran's La Mascotte opened in Paris on 28 December 1880. Its heroine, Bettina, is sent to tend the turkeys of an unlucky farmer, and she turns out to be a living good-luck charm. Luck follows whoever keeps her. Later she runs off with her sweetheart to join an army, disguised as a boy, and that army defeats its enemy.
The show traveled well. A toned-down English version was on stage from the autumn of 1881, and English took the title word as mascot. At first it meant a charm or object thought to bring luck. It was soon applied to people whose presence was supposed to do the same.
Audran did not invent the word. Mascotte was already a provincial French word for a sorcerer's charm or a good-luck piece. It is probably related to Provençal mascoto. Etymonline glosses that word as "sorcery, fetish," and OUPblog as "magic charm." A manuscript from Narbonne dated 1233 uses mascotto for an enchantment connected with gambling. Behind it stands Provençal masco, "witch," from Old Provençal masca.
The trail goes cold there. Etymonline says masca is of unknown origin. It may come from Medieval Latin masca, "mask, specter, nightmare," the same word that may lie behind English mask, but the link is uncertain. An OUPblog post on the word also hedges, saying the Latin source "is thought to" be masca, a witch.
Sport adopted the word within a decade. By 1889, Etymonline notes, it was used for animals kept to represent sports teams. The costumed characters came later.
The luck never quite left the word. A team mascot is still, in a small way, the charm Bettina was: something kept close because it is supposed to make you win.