Mirzaagha the code I shared can be added to the root extend.php file provided by Flarum for local extenders.
If you have added other local extenders in the file you need to make sure to add every extender call in single PHP array returned by the file. If you don't have any other extender you could replace the entire file with my code, as I included the import statement and array with the code.
If you don't feel confortable modifying code, best to wait for someone to package this into an extension, or for the changes to be integrated directly into TextFormatter.
I have never used the YouTube lite extension but I assume it creates an iframe with all the recommended attributes, hence why it doesn't have the same problem. TextFormatter still uses an old version of the YouTube embed iframe that used to work but no longer does on modern browsers.
@JoshyPHP perhaps you'd like to weigh in, can/should the allow and referrerpolicy be added to the MediaEmbed default site template? I took a look at the code but I'm not even sure where I would add those attributes in the youtube.xml definition. Even if this change is applied and fixed in TextFormatter, it will probably only be for Flarum 2.0 since the newer TextFormatter releases aren't compatible with Flarum 1.x.