You will be able to use i5-7400 on the Z170. HOWEVER, you MAY need to update the motherboard bios for compatibility with Kaby lake.
The i5 is locked, so you won't be able to overclock it, although I'm not sure about base clock method, you might be able to.