Can a sketch write to EEPROM while it is running.?

Stick and wrong end.

You can write in the loop function but not every time round the loop only when data needs to be written, like when you find a new turning.

To test for any value use an if statement.

Erase is an odd concept in this context, writing zeros is erasing as is writing all ones in a byte.
There is no such thing as erasing memory always has to have something in it.