If the device can run PostmarketOS with a mainstream kernel, then it can run any Linux distribution. (I put Arch ARM on such devices, since I like that distro.)
That's the big hurdle though - mainstream kernel support.
For most devices, even if they can be rooted and jailbroken, you're stuck with the kernel they come with. Doesn't have a new feature you need? A horrible security flaw in the network stack? You're out of luck. Most "repurpose your old phone" approaches have this problem. You can make it a server but you wouldn't want to expose it to the public Internet.