It might not be exactly what you want, but if the skill is a certain skill type under Type, and you use the item on an actor/class who doesn't have the skill type, then they won't learn it anyways, or at least the skill won't show up under their skills window. Unfortunately, the item will still be consumed.
Another workaround is to make the item non-consumable and call a common event instead to determine who should learn the skill or get a "no effect" message and whether to remove 1 of the item from inventory.
Not sure if there's a better way though.
I was thinking common event too; On my end, my solution for my project was to make it event-based (with clear signs/tells about who would get what). Sure, its not as exciting/convenient as using a book from your inventory but hey its easy to implement and make it works (without fail).
Something I do in my projects is make the grimoires as a weapon type. Then, under the Traits section, there's an "Add Skill" tab where you can set a skill to be known by the wielder while that weapon is equipped. I personally like this method the best because it gives players a purpose in keeping equip items instead of just selling them. I tend to do this with my weapons and armor equipment because of this.
If you are set on using a "Learn Skill" item, I'd go the route of a Common Event, or better yet, I'm pretty sure there's plugins where you can restrict the item use to specific actors.