sudo i2ctransfer -f -y 0 w1@0x3f 0x06 r9
The second, third, and fouth bytes returned from this command will give the firmware version. The byte order read out is the least significant byte first and most significant byte last, so technically it is the last three bytes of the 0x06 register (with the first byte representing the number of bytes in the register).
Example output:
0x08 0x01 0x01 0x00 0x00 0x50 0x44 0x35 0x4c
Here the firmware version is 1.0.1