According to Nicholl, music was one of the accomplishments of the boy Leonardo. He went to Milan in 1842 (not a boy) not as a painter, but as a musician. He played the 'lira da braccio' 2 drone-strings open and plucked (the lira part of the instrument) and 5 melody strings played with a bow and fingerboard. And it is known that Verrocchio had a lute so, it is possible. He might at least have composed both, music for lute and lira da braccio.
No compositions remain, only phrases from the riddles (pictorial, musical and verbal symbols) he invented (half a dozen in the Windsor Collection). Here a melody by Leonardo DGAEFDE AGEFG.
And not part of your question but, in 1493 Isabela d'Este commissioned Leonardo the instrument-maker to make her a guitar "with as many strings as he liked".