Hello @Netanel Hadad ,
although it's possible to connect to the Azure IoT Hub using native MQTT, it's recommended to use one of the Azure IoT Device SDKs for intrinsic robustness.
Regarding the HSM usage, I do not see an example mentioned. You can always open a request issue on GitHub (see the examples link).
You can connect directly to an IoT Hub but it's also recommended to connect to the Azure IoT Device Provisioning Service. It redirects your device to an IoT Hub based on current or future rules.
If the response helped, do "Accept Answer". If it doesn't work, please let us know the progress. All community members with similar issues will benefit by doing so. Your contribution is highly appreciated.