The advent of Industry 5.0, driven by cutting-edge 6G technologies such as immersive cloud eXtended Reality (XR), Autonomous vehicles, holographic communication, and Digital Twin (DT), is set to trigger a substantial upswing in the deployment of the Industrial Internet of Things (IIoT) devices interconnected within networks. This expansion of IIoT devices will create a wider attack surface and increase the risk of data breaches, privacy violations, and system disruptions. Therefore, it is essential to design innovative mechanisms to ensure the reliability and security of these advanced 6G applications, as well as the IIoT devices that support them. In this context, we propose a novel Software-defined Networking (SDN)-based Ensemble Learning (EL) Framework for Secure IIoT applications in 6G and beyond, called AdaptSDN. The proposed framework leverages SDN technology to dynamically allocate network resources and deploy security measures on demand. It also leverages EL techniques to improve the intrusion detection system’s accuracy. By isolating IIoT devices into network slices, the framework limits the impact of attacks and reduces the potential for cascading failures. Digital twins are used for creating a virtual replica of the IIoT network, allowing for a real-time security threat detection. In particular, AdaptSDN includes three main modules: (1) A novel digital Twin (DT)-enabled data gathering and selection of informative features module to achieve two main objectives: reducing computational complexity and improving detection performance; (2) An SDN-based lightweight adaptive boosting module that uses an advanced boosting EL techniques to dynamically adjust weights and to effectively identify and respond to IIoT attacks in real-time; and (3) A zero-touch resources provisioning module that employs a non-cooperative game theory approach. This approach allows for automatically provisioning various resources in a network to efficiently mitigate network attacks; it enables SDN nodes to obtain the required virtual resources, i.e., storage, computing, and bandwidth, from the main orchestrator with respect to IIoT attack type. We carried out comprehensive experiments to assess the effectiveness of our proposed framework in detecting real-world IIoT attacks. The numerical results confirm that AdaptSDN has the potential to enable secure and reliable IIoT applications in 6G and beyond, meeting the stringent service requirements of the new emerging applications.