It might theoretically work, however this is not something we have explicitly tested (or can officially support). When the control passes from the bootloader to the main application, the variable would get rewritten by the initialization code, and that may trigger weird bugs.
Either way, it could be worth trying. The variable name is s_FastSemihostingState in FastSemihosting.cpp. If it doesn’t work, making some sort of a syscall mechanism between the bootloader and the main application could be a better option.