Well, a simple way is to record the fact that it is in use as a database entry, or in a separate file. You might want to record the time the lock was acquired, otherwise you might end up with a situation where a file is eternally in use because the user who obtained the lock never got round to releasing it.
That said, it may be better to take the approach of some version control systems: instead of obtaining a lock, attempt a merge. If an automated merge is not possible due to conflicts, get the user who attempted the merge to resolve the conflicts manually. However, this is a far more complex solution, but it does allow users to have write access to the same file simultaneously, thus not blocking their work.