Basically you can use our TF6701 function blocks in order to have a bidirectional MQTT communication channel with a message broker.
There is plenty of documentation and examples available on this topic, please check TwinCAT 3 Functions section on Infosys.
Link1:
link2:
To understand more the needs of IOT license with Beckhoff, Check below picture.