Usually, if you battle a pokémon, it will either calm down or allow itself to be captured, thus ending its rampage. My advice would be to obtain a fire-type pokémon, as these are particularly effective with chasing skarmory away. The most effective in this case would be a pokémon that possesses the ability Drought (most notably torkoal, charizard equipped with charizardite y, and very specific breeds of standard-form vulpix and ninetales), as they possess the inherent talent of summoning Sunny Day at the start of every battle. If you can’t find a pokémon with Drought or if you’d like to supplement your team, also obtain a fire-type that can either fly or hover (chandelure, talonflame, baile form oricorio, etc.), as these will be important for getting as close to this skarmory as possible.
If it isn’t intimidated by your fire-type choice on the outset, prepare to battle. Use distance moves but take care to keep property damage minimal. (This would be why your flying or hovering pokémon would be vital.) Try to drive away skarmory, but if necessary, weaken it enough to capture, then proceed to tame it as you would a wild pokémon.
Of course, also keep in mind that the invasion of an aggressive pokémon may indicate problems with its native habitat. Consider investigating this skarmory to determine where it came from and what sorts of environmental problems would drive it into civilization, especially given the fact that its appearance seems to have been abrupt. If there is indeed a problem, then this may be something you bring up to your local government at worst or attempt to also resolve yourself at best.
Good luck, anonymous!