It's a decades old word that used to mean trying to one up someone with tough talk, exaggerating, topping someone. That talk would be so high above the others, it would be the cap on top.
Now to have a good story, to have that cap, people could be... flexible with the truth, so eventually, over the years, to cap started to mean that you were telling a tall tale, a lie.
So a bit of speculation, but it’s possible that the word cap has inverted twice over the years, from a toy/fake bullet, to a real bullet, and now back to being a synonym for fake, which it originally was.
cap in the true/lie sense also has roots there, but more in a superlative sense and not guns
(n.) A falsehood, exaggeration, or lie. "Saying you climbed a V10 after a month? That’s cap."
(v.) To lie, exaggerate, or be deceitful. "He said he coded the whole app in a day, but we know he capping."