I mean, you could modify function - deserializeEngine() below, this function is to read the TRT engine file and deserialize it to create TRT nvinfer1::ICudaEngine.
You can firstly encrypt the TRT engine, e.g. just adding watermark in the TRT engine, and in this function, you read the TRT engine file and decrypt it, then deserialize it to create TRT nvinfer1::ICudaEngine.
File : /opt/nvidia/deepstream/deepstream/sources/libs/nvdsinfer/nvdsinfer_model_builder.cpp
/* Deserialize engine from file */
TrtModelBuilder::deserializeEngine(const std::string& path, int dla)