SR only applies exactly in the absence of gravity. So in the real world it is just an approximation that works well enough for predicting things where the effect of gravity is small (such as interactions between small high velocity particles in accelerators near the Earth’s surface, or between spacecraft and small bodies like asteroids far from planets, but not for things like apples falling out of trees on Earth).
In regions where it does provide a good approximation, it works just as well for accelerated as unaccelerated frames, but for accelerated frames the formulas needed to express physical laws in terms of the observer’s coordinates are more complicated.