I found some estimates, collected by the United Nations Department of Economic and Social Affairs Population Division, but they're a bit dated (2013):
The United States of America is one of the few countries with relatively accurate
estimates of undocumented migrants. Using a “residual methodology”, the number of
undocumented migrants in the United States of America was estimated at 11.7 million in March
2012 (Pew Research Center, 2013). For the 27 countries of the European Union in 2008, the
CLANDESTINO Project estimated 1.9–3.8 million undocumented migrants (CLANDESTINO,
2009). In Australia, the Government estimated that in 2012 about 61,000 persons were in
irregular situation (Australia, Department of Immigration and Border Protection, 2013). The
Federal Migration Service of the Russian Federation estimated the number of undocumented
migrants at 3 million in 2013 (RIA Novosti, 2013), whereas the OECD had estimated a total of
5–6 million undocumented migrants in Russia in 2012 (OECD, 2012).
I don't think the UN regularly collects such info/stats on the legal status (unlike for migrants in general). UN DESA has updated publications of the same kind on International Migration published in 2017 and 2020, but those two [unlike the 2013 one] don't have any stats on irregular migrants. If you have a lot of patience, you can check out the sources cited there and perhaps find more updated info from at least some of those sources.
Terminology note: the UN prefers the term 'irregular' to 'illegal', just in case you want to search UN's website for possibly more such info. (They even have a poster/note why they prefer that term.)