I would argue that the concept of "legal" has no meaning in this setting. But if Russia wins in Ukraine, everyone will call it illegal, and nobody will do a damn thing to push them out. Eventually the world will recognize it as Russian territory just like they recognized it as Soviet territory and part of the Russian Empire before that. So yeah, it will be legal.