All perfect praise be to Allah, The Lord of the worlds. I testify that there is none worthy of worship except Allah and that Muhammad, sallallahu ‘alayhi wa sallam, is His slave and Messenger.
There is no religious impediment to announcing the funeral through the loudspeakers in the masjids; the Prophet, sallallahu ‘alayhi wa sallam, announced the death of An-Najaashi (the Negus) in the masjid the day that he died, and he announced the death of the commanders of the army of Mu'tah in the masjid. The only condition is that the announcement must not include a eulogy like that of the days of Jaahiliyyah (pre-Islamic era), by mentioning the good qualities of the deceased and his achievements and so on. There is no harm in announcing the death only so that people would fulfill the right of the deceased of praying over him and following his funeral and the like.
If it is possible to avoid this by announcing the death in a place other than the masjid, then this is better in order to avoid the dislike, as some scholars held that it is disliked to make death announcements in the masjid.
Allah knows best.