How to set platformIO to only erase part of the Flash sector when downloading the program, and download to the specified Flash address area?
This is impossible to answer without knowing at least the target processor, of which there are thousand possibles, better the whole
The question is how to configure that in OpenOCD, which is what should be used here. I think OpenOCD das automatic sector erases by default and you would have to execute a special command for a full chip erase anyway. This says the same.
You can test that with by e.g. using ST-Link Utility, manully writing some data at the end of flash, then letting PIO flash the firmware and seeing if the data at the end is still there.