I created image of, for example, /data partition with
adb pull /dev/block/mmcblk0pXXX data.img
Can I use
fastboot flash data data.img
fastboot reboot
to restore it back? Or fastboot require specific, not just raw binary, image file format? If so, is it possible to convert my data.img to that specific format?
Unless you don't want to change other stuffs like boot or recovery, yes you can directly flast the data file of .img format. You are also suggested to erase the old data so that it doesn't create any previous leftover. So,
fastboot erase data
fastboot flash data file_name.img
would be the proper way of flashing a data file.
There a good tutorial regarding Adb and Fastboot Quick Guide