No, it's not possible. Only dependencies can be platform-specific.
If you already have a Linux-only crate, then Cargo's natural solution is just not try to build it on other platforms.
If you want to be thorough, you can use cfg(not(linux)) and compile_error! to break compilation early on other platforms. Or wrap everything in cfg(linux) and make it compile to nothing on other platforms.