In Pokemon Ultra Sun, I accidentally knocked Necrozma out. Where would I get it again?
Assuming you mean when you encounter it at Mount Lanakila right before the Pokémon League (where you actually have a chance to catch it), YES. Just become champion/defeat the League again and it will be waiting in exactly the same location.
Source: experience.
Yes you have to become champion and defeat the league again and Necrozma will be in the same crater where you found it. I highly reccomend to save the game before battling Necrozma, so if you knock it out again, you can just try again from where you saved.