The healthcare industry has witnessed a transformative impact due to recent advancements in sensing technology, coupled with the Internet of Medical Things (IoMTs)-based healthcare systems. Remote monitoring and informed decision-making have become possible by leveraging an integrated platform for efficient data analysis and processing, thereby optimizing data management in healthcare. However, this data is collected, processed, and transmitted across an interconnected network of devices, which introduces notable security risks and escalates the potential for vulnerabilities throughout the entire data processing pipeline. Traditional security approaches rely on computational complexity and face challenges in adequately securing sensitive healthcare data against evolving threats, thus necessitating robust solutions that ensure trust, enhance security, and maintain data confidentiality and integrity. To address these challenges, this paper introduces a two-phase framework that integrates blockchain technology with IoMT to enhance trust computation, resulting in a secure cluster that supports the quality-of-service (QoS) for sensitive data. The first phase utilizes the decentralized interplanetary file system and hashing functions to create a smart contract for device registration, establishing a resilient storage platform that encrypts data, improves fault tolerance, and facilitates data access. In the second phase, communication overhead is optimized by considering power levels, communication ranges, and computing capabilities alongside the smart contract. The smart contract evaluates the trust index and QoS of each node to facilitate device clustering based on processing capabilities. We implemented the proposed framework using OMNeT++ simulator and C++ programming language and evaluated against the cutting-edge IoMT security approaches in terms of attack detection, energy consumption, packet delivery ratio, throughput, and latency. The qualitative results demonstrated that the proposed framework enhanced attack detection by 6.00%, 18.00%, 20.00%, and 27.00%, reduced energy consumption by 6.91%, 8.19%, 12.07%, and 17.94%, improved packet delivery ratio by 3.00%, 6.00%, 9.00%, and 10.00%, increased throughput by 7.00%, 8.00%, 11.00%, and 13.00%, and decreased latency by 4.90%, 8.81%, 11.54%, and 20.63%, against state-of-the-art methods and was supported by statistical analysis.