We've been seeing the UNABLE_TO_LOCK_ROW issue in our prod org. I've created a retry for DML actions facing this issue to sleep for a certain number of milliseconds between each try and try for a certain number of times. I'm unable to replicate the error within my unit tests. I'd like to know if it's possible to purposefully produce the UNABLE_TO_LOCK_ROW error in the unit test so I can test the retry logic?
You cannot intentionally cause this to happen, because you need at least two threads in order for this to actually get thrown. Two parallel tests running at once can accidentally cause this problem, but parallel testing is disabled for deployments, so those tests wouldn't pass correctly, even if you could coordinate two specific tests to run in parallel on purpose.
In other words, this is one of those times when you would need dependency injection or Stub API mocking. Either way, you'd have to have either a DML or SOQL class to inject code in to during testing. As I've advised before, it's best to probably just assume it works and leave out the coverage. In most cases, this shouldn't even drop you 1% of your total coverage if you're doing it right.