EnderDragon ignore to get damage attacked towards the back of the body in a melee attack.
(Example of the back of the body → Legs , Tails , Stomach)
Regardless of its bug , the front of the body of EnderDragon receive damage even if in a melee attack.
I am unable to reproduce this issue in 21w19a. The ender dragon was damaged upon attacking its back body and no issue was apparent.