You could set the #[global_allocator] to change how those types allocate, but using a specific, non-global allocator for String, OsString, PathBuf, etc. is not possible.
This is an annoying limitation of the current allocator_api design, because it needs everything that could allocate to take an Allocator for maximum flexibility.
If you need a string on the stack, you can use arrayvec::ArrayString. It has a const generic for a cap on its size, and the crate also has an ArrayVec type that uses a statically allocated buffer for storing any T.
You can’t inject this into external functions that allocate like std::env::var though. This is just an optimization though, since you have an allocator that you could use.