Dear Student,
As the hammer strikes the nail with force F, the nail penetrates in and also applies the equal and opposite force as a reaction on the hammer, equal to -F. Hence the work done by hammer or nail is +ve and work done by nail on the hammer is -ve.
Regards