فَكُلِي وَاشْرَبِي وَقَرِّي عَيْنًا فَإِمَّا تَرَيِنَّ مِنَ الْبَشَرِ
أَحَدًا فَقُولِي إِنِّي نَذَرْتُ لِلرَّحْمَـنِ صَوْمًا فَلَنْ
أُكَلِّمَ الْيَوْمَ إِنْسِيًّا
Eat and drink and rejoice. And if you see any human being say, 'I have vowed a fast to the Gracious God. Therefore, I will not speak with any human being today.' (19:26)
The core meaning of the word صَوْم is to abstain. It is also used for abstinence from speaking and walking.
In the verse, it is evident from فَلَنْ أُكَلِّمَ الْيَوْمَ إِنْسِيًّا (Therefore, I will not speak with any human being today) that she was observing a 'fast of silence'.
One may ask further: how can God ask her to tell others that she is fasting when she was observing a 'fast of silence'? This is also clarified in the verse 19:29.
فَأَشَارَتْ إِلَيْهِ قَالُوا كَيْفَ نُكَلِّمُ مَنْ كَانَ فِي الْمَهْدِ صَبِيًّا
She pointed to the child. They said, "How shall we talk to someone who is a child in the cradle?" (19:29)
فَأَشَارَتْ إِلَيْهِ clarifies that she was supposed to tell them by gestures not by words.