From a purely gameplay design standpoint, "ammo" for a gun and "durability" for a melee weapon are the exact same thing. That mechanic is there to limit how much the player uses their weapons, often done to push the player into trying everything in their arsenal and not just rely on one thing they're comfortable with.
But while "ammo" is perfectly accepted as a mechanic, if gamers see "durability" they freak out and complain.
To me, the difference between the two mechanics is the ability to Recharge a pet weapon.
With ammo, if I find 5 ammo in a trashcan, I can suddenly use my favorite gun 5 more times, unless I'm already capped on ammo. And, if I'm out of ammo, all I have to do is find any amount of ammo to be able to use the gun again.
Whereas, most weapon durability systems (in my experience) make that durability loss permanent - I can't find +3 swings to my magic sword in the trash, and if my sword breaks, more often than not, I have to Go Out and Find or Buy Another - which if it's Rare/Powerful, then durability represents a Finite Number of uses EVER. Imagine a character throwing away a gun just because it ran out of ammo.
To me, a better comparison for ammo would be Monster Hunter's sharpness system - finding ammo and sharpening a weapon are downtime activities that the player engages with to keep up on their damage output during a longer scenario that, if not kept up with, can put the player in a really rough spot.
You're describing how the two can feel different emotionally, but mechanically they still serve the same purposes.
Imagine a character throwing away a gun just because it ran out of ammo.
I have seen countless FPS where you do literally that though, especially in the mid-2000s after everyone copied Halo for only letting you carry two guns at once. A gun only functions if there's ammo in it. An empty gun is as useless as a broken sword waiting to be repaired.
There's plenty of games where melee weapons can be repaired and restored to full durability by spending a ressource. The last few Resident Evil games have a system where you craft ammo by using gunpowder. In other words you could say you are restoring your guns to full usability by spending a ressource.
Functionally these mechanics serve the same purpose, but the way they are each narratively dressed provokes different feelings.
I appreciate the examples (I'm very unfamiliar with Resident Evil games because I'm a tiny baby about horror) - but I think there's a crux of the argument that i was making that didn't quite come through.
Which is, the difference between how players react to a system like this comes down to agency and the effort required to get the player's pet weapon back to operational.
You mention Halo and other FPSs where throw away their empty weapons because of limited inventory - but it's the player choosing to throw away the empty gun rather than the character. A player is more than welcome to carry around an empty gun if they want, despite it being a bad idea, until they get more ammo for it. And ammo can be hard to find, sure, but picking it up gives that exact number of extra uses no matter how much other ammo you have (unless you're capped on that ammo type, I guess).
Where as, when I think about weapon durability I mostly think about things like older Fire Emblems or Breath of the Wild, where have the specific number of swings of the weapon, it breaks and you have to get a new one. There's no "oh hey I found 3 silver nuggets so I can swing my sword 3 more times this battle" - if you use the weapon too much, it's gone, and it takes effort to reacquire it and usually no way to give it more uses in the meantime. And of course, that's without mentioning the one-off weapons that pre-3DS Fire Emblem loved to hand out that fell into the classic RPG problem of players hording them until they were sure they needed it.
I agree that fundamentally the two mechanics can be interchangable - they serve the same purpose of putting a limit on how much you can use a given tool. They can also be used interchangeably across any set of weapon types a designer wants.
However, I think the crux of why they feel different, why gamers "freak out and complain" about one and not the other comes from that feeling of permanency that many weapon durability systems come with. It's the complexity and difficulty of buying, upgrading or finding an entire new weapon versus being able to slowly regain uses for that weapon, regardless of state.
Edit: I have been informed that I had zero idea about Halo's core mechanics, mea culpa. Which makes the whole thing more interesting because of the blurring of the lines it offers, though I feel like the crux of the argument still stands - that the difference in feeling between the mechanics is tied to whether or not a loss feels permanent.
