The headwind will decrease our groundspeed and this will increase our flight time.
But if our airspeed remains unchanged then our fuel flow rate will also remain unchanged.
So for each hour of flight we will burn the same amount of fuel, but we will have flown less distance over the ground.
So headwinds will decrease our max range.
To reduce the amount by which our max range is reduced, we need to reduce the amount of time that we are fighting against the headwind. To do this we must fly a little bit faster.
But if we make the mistake of increasing our airspeed too much then the additional fuel that is required to provide additional thrust equal to the additional drag, will outweigh the benefit of reduced flight time. This will reduce our max range.
So speed for max range in a headwind is slightly higher than it would be in still air.
But the overall effect is still a reduction in max range.