I've seen M18 battery kits which include everything you need to make your own pack minus the cells. Most are "5.0" (10 cells) & "9.0" (15 cells) size. I've also seen replacement tops like what you are after. No idea if those case molds are the same as Milwaukee & fit genuine Milwaukee packs.
But keep in mind these are for 18650 cells which are a different case size. You need for 21700 cells which are longer & wider. Also for the M18 18650 packs there were older version cases where the case halves won't interchange with the newer case design, they're constructed differently.
I would assume all the 21700 packs are constructed the same (top half all the same) but I'm not for sure. I've only taken apart my 12.0 before & never any of my other 21700 packs. No idea if there was an older style case for the 12.0.
Edit: Looks like they are available but again no idea if the top fits a genuine MW battery. The 12.0 is pretty heavy so depending on how/what broke on yours it might not hold up long term? For what a 12.0 cost new, $30 might be worth a try. It's from a 3rd party seller though, looks like it ships from China. Might be other listings. And it may be cheaper ordering from aliexpress.