I can't vouch for what would happen if you do this in Sword/Shield, but I imagine it's similar to what happens in other recent games.
Specifically, on Ultra Sun or Ultra Moon: