First step: You need to tell the compiler that it's not allowed to optimize out the variable if it's unused. Use e.g. the [[gnu::used]] attribute.
If you want to be able to access the variable in other source files, you also need to mark it extern (constants have internal linkage by default in C++).
Second: You need to stop the linker from throwing away your unused section. Either remove the --gc-sections flag in ~/.arduino15/packages/arduino/hardware/avr/1.8.6/platform.txt, or add -Wl,--undefined=MY_VERSION.