—for I categorically forbid you to do so. Numerous other hadiths likewise prohibit this repugnant practice, a practice that ultimately turns graves into idols that are worshipped instead of Allah, for which sacrificial animals are slaughtered and to which vows are offered, exactly as the questioner has mentioned. Such behaviour belongs to the days of ignorance; it is what the Jews and Christians did with their prophets and righteous men. It is also what led the people of Noah, peace be upon him, into associationism when they went to extremes concerning the righteous and the dead and ended up worshipping them instead of Allah. We ask Allah for well-being and safety.
What the Prophet ﷺ warned against has, regrettably, come to pass in this Ummah: in many lands graves have been taken as mosques, domes have been built over them, various forms of worship have been directed to them, and people seek their needs from them rather than from Allah. There is no might nor power except with Allah, the Most High, the Mighty.
As for the matter at hand—whether the grave should be removed from the mosque or not—the Muslims must examine it carefully. If the grave predates the mosque and the mosque was later built over it, the mosque must be demolished and the grave left as it is, for the grave has prior claim. Such a mosque is founded upon associationism and upon disobedience to Allah and His Messenger; accordingly, it must be torn down.
If, however, the opposite is true—that the mosque was originally built on a sound legal basis and upon correct belief, and only afterwards was someone buried inside it—then the grave must be exhumed and removed from the mosque, the mosque restored to its proper status, and the community freed from this grave offence.
This is what is incumbent upon the Muslims. If you possess the authority and the ability, then put it into effect.