I heard there is an IoT Hub Gateway. Would this allow me to add custom steps for handling messaging when they go from the device through the gateway?
Yes, there is an Azure IoT Hub Gateway SDK which is designed to be modular so any step you need to take can be a custom build module running within the Gateway. You can 'stack' modules to determine a flow for message handling.
Like this: Decrypt->Convert2JSON->Add Metadata->Map to IoT Hub device ID-> Encrypt-> etc.
You can find the sources and documentation here.