The firmware of the printer reads the g-code, in this instance, for z-axis movement. The g-code provides only (primarily) millimeters of movement and direction, along with speed.
The firmware reads those figures, figuratively speaking, and knows from the values stored in the firmware, how many steps to rotate the motor, in what direction and at what rate.
I suppose if you were a glutton for punishment, you could write some code to convert the existing measurements to ones that are adjusted for the new screw, but that's just crazy. Imagine that your new screw provides for 3.729 times the movement that the old screw did per unit of rotation. You'd have to find all the z-movements in the code and apply that factor to those numbers. I suspect rounding errors might make for a less-than-satisfactory print.
As you've mentioned in your question about editing the firmware, one may expect that you have an idea what is involved. If not, that may be the topic of another post.