It's possible to download the bootloader and work out which type/version it is. With enough determination, and working outside the Arduino IDE, you could do this as part of the upload process and define corresponding preprocessor definitions to get the appropriate code options compiled in. It does not seem like a very practical approach though. An intermediate solution would be to download/recognise the bootloader manually and then manually edit #define assignments within your sketch to reflect that before building it.
If you were willing to customise the IDE installation, you could define a different board type for each board/bootloader combination and define some bootloader-specific preprocessor definitions. That would still rely on your manually selecting the right board/bootloader type within the IDE.
I guess that what you're really hoping for is some way for the sketch to work out where the bootloader code is stored and read the code to work out which bootloader it is. I'm not sure, but I suspect that the sketch doesn't have access to program memory containing the bootloader. Even if it did have access, finding and analysing the bootloader would be an extremely difficult task and I doubt that it would be practical to do this generically i.e. supporting different chip types and bootloader section sizes.