Can the software of a (non rooted) phone affect its charging when turned off?
Theoretically possible

I am not a developer but interested in charging and this is what I know software or OS does:


Monitor battery level and display it on screen and internally trigger warning actions
Detect that a power source is connected
Depending on the type of power source and battery level initiate normal charging or fast charging
Again regulate charging power depending on battery level, reducing it as battery gets closer to full charge
Interact with battery files that are coded in Kernel


There could be a lot more that I am not aware of,  but that said , if any of these functionalities are broken, it would affect or disrupt charging, immaterial whether the phone is on or off ( see second bullet - it won't charge whether it is off or on, if it can't detect power connected)

So yes, it's possible but is it probable ? I don't know , with the details shared

May as well factory reset and hope it fixes your problem and being new you can always return it if the problem isn't fixed