I got more length of the SATA cable to work with by removing the fan and routing the cable differently under there (right through the middle instead of around the edges). However, then the adapter cable turned out to be too long, the whole thing would have gotten in the way of the display. Since I read that the Mid 2017 iMac doesn't really need the sensor, I'll be trying it without. Otherwise, my solution would have been to bend the adapter under the cage and tape it in place.