See Master User folder in home_dir - #3 by garvamel, one can define a new system environment variable PLATFORMIO_HOME_DIR to the path of where the .platformio folder should be globally (docs), or one can set it per-project using the home_dir option in the platformio.ini file of the project (docs)
Update for PlatformIO 4:
It’s now called PLATFORMIO_CORE_DIR (docs).
Also see Redirecting....