The trick is not to think of it as synchronizing the motors so much as it is setting them both to a commanded speed. That means each motor is its own separate unit, with its own PID loop. You then synchronize the motors by sending them the same command. This gives you the option to send them different commands, for things like steering or compensating for mismatched wheels.
For each motor, the first thing to do is measure the speed. You can do this by measuring the time between encoder counts and dividing the amount of distance covered in a single count by the time difference.
Now, you have the actual speed and you have the desired speed. Subtract that actual speed from the desired speed; this gives you the error. The error value is the input to the PID loop. The output from the PID loop, once it's correctly tuned, is the PWM value to write to the output for that motor.
The link I provided has a lot more information on how to set up and tune PID loops. It's pretty good; you should read it.