There is no restriction on how close a mansion can be; they are usually far away simply because they are so rare. I don't know the exact abundance but the base chance is one mansion per 80x80 chunk (1280x1280 block) region, which only succeeds if the biome at a single point within that area is Dark Forest. According to this thread Dark Forest is 2.3159% of all biomes, which would give a probability of one mansion every 276350 chunks, an area 8411 blocks on a side, more than twice the size of my largest world, which is equivalent to a square about 5542 blocks on a side. A 1000 block radius around spawn, assuming a circle, is about 12272 chunks, so the chance of a mansion within this area is about 4.4% (about one in 22-23 seeds).
However, the actual probability is even lower since the area within a 32 block radius of the mansion must be entirely Dark Forest (Hills), at least according to code for 1.12 (this area is not properly centered so parts of the mansion can extend into other biomes). The Wiki only says that they typically appear tens of thousands of blocks away; it would be possible to find the exact chance though by writing code that scanned a vast area and counted every successful attempt.