Assigning the task ID to a field in the current item:
You can access the Task ID from the within the task behaviour. Click on "Change the behaviour of a single task"
The best place to set the field in the list / library would probably be in the "Before a Task is Assigned" "When a Task is Pending". You can add a "Set field in current item" action or if you wish to assign it to a workflow variable you can use the "Set Workflow Variable" action.