I'm only just researching how to fettle with them myself, but so far I know that they come in only a few different diameters, with the vast, vast majority on most adult bikes being 160mm or 180mm. So that's clearly a case of just measuring the diameter of the old rotor.
Then there are two fitting types, there's a centre lock ring (which looks to be commonly the Shimano option) or a 6 bolt fitting. You need to just remove the wheel and have a look at how your old one fits on. To remove, you'll need a cassette lock ring tool for the former, and hex bolt / torx head bolt keys for the latter.
One instruction I've noted and hadn't previously thought about: You need to make sure the rotor is orientated in the right direction, they take the braking load in one direction. There will be an arrow on the rotor indicating direction of travel.
If you're unsure or are lacking the tools, I'd ask your local bike shop to do it. If you fancy a go, there is more detail here:
https://road.cc/content/feature/171890-how-fit-disc-rotors