As the documentation says, getPixelsPtr returns a read-only (ie, const) pointer. If you really want to break the API and modify the data directly through that pointer, you can use a const_cast to make the pointer non-const, but as soon as you do this SFML is no longer responsible for whatever might happen.
You should probably use the getPixel and setPixel methods instead.