This is the first step which needs to be taken, so please decide which firmware you want to use. Pretty common firmwares are Tasmota, ESPEasy and several others.
For Tasmota, there is even a step-by-step openHAB tutorial:
Please make sure you are following the new mqtt2 binding version setup, not the outdated mqtt1:
This will ensure your ESP8266 device is able to communicate with your mqtt broker and you will be able to configure your ESP8266 through a nice web interface.