A lot of slang comes from street language, so that thought may still be right. :)
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.
Etymology: like others said, the old version of cap was short for a bullet. And that term most likely comes from “cap guns” which are/were you guys for kids that had a tiny tiny amount of gunpowder/similar so they made a small noise when fired.
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.