I spent my whole life studying to be a professor of History. I did my AA, BA, MA, and part of my PhD in various sub-fields of History. I was enthusiastic about the career for the majority of that time, but while in graduate school I began to get the sinking feeling that I was not as interested in the field as I'd thought. I also kept getting the unshakable feeling that I was wasting my life. My other friends were out in the workforce, getting married, buying homes, and I was still hobbling around a library writing papers in the wee hours that would ultimately never be read by...anyone.
I left my PhD after realizing that while I probably had the ability to finish it, I did not want to pay the expense of 3-4 additional years of virtually unpaid labor. The likelihood of landing a professorship was low anyway because of the state of my field and of academia in general.
Three years later, I am now a junior software engineer. My job is challenging, rewarding, and a source of pride. It pays me a livable wage. And it's a tremendously good investment for my future. I shudder to think of what might have happened to me had I stayed in academia: cobbling together a living in "adjunct hell" or moving to some Nebraskan cornfield for a tenure-track position at a community college. No thanks.
To be sure, Physics PhDs have more career options - but not as many as you'd think. You'd have to slide your way into a hard-skill position somewhere and lean on your math skill set heavily, in the event that you could not land a professorship or a research position in aerospace (or wherever your interests lie).
However, learning to code is a great idea regardless of whether you stay in Physics, because it is a highly employable hard-skill, even among scientists. I'd look into Python specifically for its role in data science and its usefulness in science research careers. You literally cannot waste your time (as it relates to money or career goals) by learning to code.
Leaving the PhD might not harm your future applications to PhD programs, but it certainly does not do you any favors and you'll need to explicitly address/justify this choice in your new application. The first question they're going to ask is, "Should we invest in this applicant, knowing s/he already left one program?" There are even a few folks in academia who snobbishly refer to leaving the program as "washing out." These people are urchins, but some of them hold clout and occupy positions of power in your target school/program.
You also need to consider how exactly to explain your decision to leave the program. The wording is critical. If you make any indication whatsoever that your decision was informed by whimsy, they might ball up your application and practice half-court shots with it into the trash can. Your decision to leave the program needs to be part of a thoroughly strategic plot to further your career goal: "As I proceeded through my program, I found myself gravitating more and more towards climate science [specific reasons/examples etc etc]." You decided to return to the private sector, brush up on your ancillary skill sets, and then move into a program that better suited your interests. And you loved your former program, advisor, and colleagues. You need to appear that you've got a plan and you've got yourself and your goals all buttoned up.
The "unrelated" job doesn't have to be unrelated if you can weave it into the larger tapestry of your career goal. If coding is relevant whatsoever to jobs in climate science (hint: it is), then you can swing that experience like a truncheon in your application. Plus, having any "real-life" professional-level work experience is a great thing on any PhD application because it indicates that you can work on a team, follow orders, and complete complex tasks. My university (in the US) would rarely accept PhD applicants from recent bachelor's grads because they had not yet had any professional work experience and basically had never "adulted."
One last thing to consider is the fact that you are being offered a job that will allow you to develop a critical skill: coding. That in itself can turn into an incredibly rewarding and lucrative career, if you cultivate it properly. You'll be making money immediately and your job options will open up over time. If you return to academia, you will spend years making very little money, with no real guarantee of a lucrative career afterwards (this point is controversial but the debate over whether PhDs have a good return on investment is something you should absolutely read about).
I mention this last bit only because I think a new career has presented itself to you and you might not have realized it yet.