Some time ago I bought a couple of Yubikeys, but actually start using them ended up on the todo list.
But now I can easily unlock and lock my apple laptop with my yubi key. Unlocking is just done using the standard pam module and the configuration described at the yubikey website.
But getting my screen locked when I unplug the device needed some extra deamon. There is an option to lock the laptop when you unplug the yubikey in the advanced security preferences, but it did not do anything for me
I found a small project at https://github.com/shtirlic/yubikeylockd.git dealing with just that. So now running this small daemon, my screen is locked as soon as I unplug the key.