The pistol comes to you through Leonardo, and you need a specific scroll to get it working.
Someone hands you the scroll as you progress the story. Take it to Leonardo and he will use it to build the firearm for you. There is nothing to buy and no side quest to complete beyond making that delivery, so if you do not have the gun yet, the scroll is the thing to chase.
Once you have it, the pistol is a single-shot weapon with a long reload, so treat it as an opener rather than a mid-fight tool. It is excellent for starting a brawl from a rooftop or picking off an archer before a stealth approach goes wrong, and considerably less useful once you are surrounded.