Generally, one can switch research focus and even, perhaps, subfield or even field, if you have a stable position from which to work. If you are a tenured professor in some aspect of physics then there is little to prevent you from examining and moving to another. It is helpful if you have colleagues in the new area so that you can easily get guidance, but that is available elsewhere if you work at it. Of course, you need to keep the department happy about your work but that doesn't necessarily imply being limited to one narrow area.
I switched focus a number of times over a long career, though not in physics.
But it is probably not possible to do so immediately after earning a doctorate as you will not yet have anything to show in the new field making it difficult to get hired.
What you can do during your doctorate depends on how intense it is and on the opinions/needs/desires of an advisor. There is probably some opportunity to dabble a bit but intense study is pretty hard even in one field.
If this is your plan, then you might consider either switching to the new field now or deciding to put it 'on the back burner' until you are fairly well established.
But it is always a good idea for an academic to look at new and different things and to take advantage of opportunities that arise if they seem interesting. Don't. Be. Bored.