Apple themselves claims that roughly 80% of the emissions of an iPhone comes from production; with the remainder being transit, use, and end of life recycling. As far as electronics are concerned, the best thing you can do is defer upgrading as long as possible.
Interestingly enough, the same is true for cars. It’s often better to just keep using an older car until it dies from a CO2 perspective (sometimes older cars emit other pollutants that makes this more complicated). Depending on the exact mix of electricity production in your area, it can sometimes be greener to use a used gasoline car than a new EV, although that is changing as energy production shifts towards renewable sources.