The only way to do this at present is to make a custom keyboard layout with Ukelele. It lets you add any icon you want to a keyboard, but also includes in the Resources folder in its download some .bundle files which have a number of the former layouts with their flags.
To install those layouts, put the .bundle file in Home/Library/Keyboard Layouts. To get to Home/Library, do Finder > Go while holding down the Option key.
If you need the Ukrainian layout with flag, try this.
I have not seen any official Apple notice regarding this change, which occurred May 16, 2022. Of the more than 100 keyboards in MacOS, already more than half used the country/language code type format instead of a country flag. It's possible that recent requests to decouple Russian script input from that country's flag led Apple to decide to move totally to this format.
This change may be a direct result of a companywide effort not to denote languages using country flags on Apple’s part.