Unless you are at 20k ft and doing Mach 1.5, its unlikely to be worth firing at this kind of range.
The best way to know whether a shot is worth it or not is reading the radar:

On the B-Scope display (the square radar panel) on the right hand side is a set markers that will tell you all you need to know about whether or not the target is within range and its worth firing
LIne 1 is your minium range (or rMin). if the target marker is below this point, the missile will be unable to hit the target, less of a problem for more modern missiles, but well worth keeping an eye on for older ones
the Box labeled “2” is your LSZ (launch success zone) or NEZ (no escape zone) (varies for different air forces but its the same thing) A missile fired within this box is incredibly difficult to defeat kinematically, the target will be required to actively defeat the missile, even turning cold wont necessarily be enough to defeat a missile fired within the LSZ
Note, the LSZ boxes can be buggy, especially at high alt and can sometimes appear to exceed the rMax, this is impossible, so do be warned, but generally can be trusted
Line 3 is the targets current relative range on the scale, if this line is within the LSZ box or close to it, generally its a good idea to attempt to fire the missile.
Line 4 is your maximum range (or rMax), this is the maximum theoretical range of your missile, but just because the target is within range, it doesnt mean that a shot is worth while firing, only that if the targets fails to do anything, the missile should hit. Its definetly worth paying attention to this for shorter range weapons like the Aim-9M.
So to summarise, try firing the missile whilst it is within the LSZ on the B-Scope and you should have greater success hitting the target. This range display is found on most aircraft and most weapons. But LSZ box is not modeled for all weapons.
Also pay attention to what the target is doing. TWS will give you the targets heading, if its traveling towards you, then it will be harder for them to defend than if they were already in a notch and if they are turned like that, then they wont be able to fire straight away and you can safely get closer. Control the fight. If they’ve been flying back and forth, they have probably drained a lot of energy and thus a good target to fire at.
A target at a very high alt will also struggle more to get into a notch than one at sea level and I personally find control surfaces can get a little… squirelly. So a target at very high alts may struggle to defend far more than one low, so these targets are usually ones I tend to single out
As a final piece of advice, try to help the missile as much as possible, Aim-120s dont like being fired at wierd angles, so leading your shot helps massively, the game already provides a lot of help with this, aim for the circle and the missile should have the easiest time. You can also raise your nose 15-20° and loft the missile slightly which can help too.
