One low cost possibility is to use a regular "front wheel pickup" cyclometer and mount the handlebar bracket on the top tube a few inches ahead of the saddle. That way, a regular length wire will reach the rear wheel and the pickup switch can be mounted on the chainstay or seatstay.
Yes, you will have to read it sideways and, yes, you will have to look straight down to see it but, on a trainer, so what?