You can write a plugin that captures the state change, implements your validation logic, then throws an exception if validation is not met. That should cause the state change transaction to roll back. Of course your user will see a 'Business
Process Error' as a result.
An alternative would be to disable or lock the Activate/Deactivate buttons on the Entity's Ribbon Bar.