...agreed with the sources brought by @user6781.
Further, the baalei mussar (mussar masters) explain that middah keneged middah is a chesed (kindness) of Hashem, which allows people / person to determine the manner in which they have sinned, in order so that they can do teshuvah. There seems no reason that this kindness should only apply to individuals and not to a community.
As a more recent example, I heard from Rabbi Matisyahu Salomon that the Chafetz Chaim said that the Wall Street Crash (that led to the Second World War) was a punishment for people reading newspapers that promulgated apikorsus (i.e. the apikorsus of cause and effect).
Slightly related, the Imrei Emes said that the holocaust did not on the whole affect the Sephardic community because they do not talk in shul. Although Reb Matisyahu's interpretation of that statement is not that the holocaust came because people talked in shul, but rather that since people talked in shul, they had desecrated their own shuls and therefore their prayers to be saved became ineffectual. (So this is not exactly the same case as the current discussion.)
More generally (along these lines), the gemara says in Bava Metzia (30a)
https://he.wikisource.org/wiki/%D7%91%D7%91%D7%90_%D7%9E%D7%A6%D7%99%D7%A2%D7%90_%D7%9C_%D7%91
דאמר ר' יוחנן לא חרבה ירושלים אלא על שדנו בה דין תורה אלא דיני דמגיזתא לדיינו אלא אימא שהעמידו דיניהם על דין תורה ולא עבדו לפנים משורת הדין
Rabbi Yochanan said, "Yerushalayim was destroyed because.. they were insistent on standing on their rights according to the strict law of the Torah."
The explanation of this gemara (which contradicts others that state that Yerushalayim was destroyed because of baseless hatred) would seem to be along the lines of Reb Matisyahu's explanation above, i.e. according to the allegorical notion of
https://he.wikisource.org/wiki/%D7%9E%D7%A9%D7%A0%D7%94_%D7%A1%D7%95%D7%98%D7%94_%D7%90_%D7%96
בַּמִּדָּה שֶׁאָדָם מוֹדֵד, בָּהּ מוֹדְדִין לוֹ
In the measure that a person measures to others, is reward/punishment delivered to that person.
This means to say that Yerushalayim was not destroyed because the people were insistent on their strict rights, but rather that when Hashem came to judge the people concerning their baseless hatred etc., there was no room to be lenient, because corresponding to the people's actions they deserved to be treated according to the strict letter of the law.
So we have 2 notions in the idea of middah ke'neged middah. One is that a person can be punished with exactly that thing with which he sinned (e.g. water in the case of the Egyptians). And another idea is that a person is punished using the Divine attribute corresponding to the harsh personal attribute which he invoked in his dealings with other people.
In the case of Coronavirus, since the reason for any action against the anti-vaxxers was in order to protect the community from disease, it is not possible to say that a punishment should occur middah ke'neged middah for these actions (with regards to the second notion of middah ke'neged middah), because this treatment was one born of concern and not of selfish harshness. Simply put, it is not possible that we should say that Hashem should punish someone or a tzibbur for doing a mitzvah.
Concerning the comparison to Kamtza and Bar Kamtza:
In that case, the gemara says that since Bar Kamtza was publicly humiliated. Hashem allowed him to avenge himself of his humiliation, as the gemara says
https://www.sefaria.org/Gittin.57a?lang=bi
תניא אמר רבי אלעזר בא וראה כמה גדולה כחה של בושה שהרי סייע הקב"ה את בר קמצא והחריב את ביתו ושרף את היכלו:
"To conclude the story of Kamtza and bar Kamtza and the destruction of Jerusalem, the Gemara cites a baraita. It is taught: Rabbi Elazar says: Come and see how great is the power of shame, for the Holy One, Blessed be He, assisted bar Kamtza, who had been humiliated, and due to this humiliation and shame He destroyed His Temple and burned His Sanctuary."
I.e. Bar Kamtza "felt better" after his humiliation had been redressed by the destruction of the beis ha'mikdash. This redressing was valid in the eyes of Hashem, Who therefore allowed the destructive chain of events described in the gemara to take place.
If we were to say that the treatment of the anti-vaxxers is analogous to the story of Kamtza and Bar Kamtza, then we would have to say that the anti-vaxxers were humiliated by the "establishment", and therefore the "establishment" was smitten by Hashem with a disease for which there is no vaccine, which punishment ameliorates the humiliation of the anti-vaxxers. I.e. we would have to say that the anti-vaxxers were happy that the general community was visited with Coronavirus.
It is impossible that the anti-vaxxers are happy with that outcome, for if they were, you would have to say that they were happy that people had died, which obviously they are not. Therefore there is no analogy to the case of Kamtza and Bar Kamtza.