See the Make_random functor in the janestreet Bigint library, which is built on top of zarith. (It's a functor to produce random distributions based on both Random.State.t and Base_quickcheck.Generator.t; the functor itself is not exposed.)
In short, we generate 30-bit chunks of randomness until we have at least enough bits for our range. We combine those into a number. Usually, we just modulo that by the range and return it. But to preserve fairness, we first have to check if the number is in the last fraction-of-range part of the N bits, and if so retry from scratch. The odds of retry are always less than 50%, so retrying is never too bad.
This is the same trick that Random.int does, but with an unbounded number of bits instead of a fixed number of bits.