This is a procedure performed by a vet on very young dogs- just a couple of days old so as to avoid undue discomfort and stress. The bones and nerves in the tail have not yet formed and it is a relatively painless procedure.
Typically it is performed when the puppy is a few days old. Their nerves aren't devloped through the tail at that point so while it hurts, it's not brutal.
Yorkshire tails should be docked within the first five days of birth or else it is better to leave it natural, this also depends upon the country you live in, most countries have laws against docing of tails in dogs.