At first you will need png images for the flags . Download the flags for your layouts.
Open gimp and rescale them to 26x10 (width x height). Rename them to your layout language
like for US layout rename the image as "us.png", for Russian rename to ru.png and etc.
Then put them in ~/.icons/flags.
After that install dconf-editor (if not installed). Open dconf-editor and go to
org/mate/desktop/peripherals/keyboard/indicator and check the "show-flags" option.