I've done a number of difference types of giving urine samples.
The usual in a sterile container at the doctor's. When I was young, we would do this at home and bring it in a small glass jar, from jelly or baby food. Since my teens I just do it at the doctor's in one of their plastic containers.
I've had a couple pre-employment drug tests. One was like others have said, emptying pockets, and having nurse waiting outside the door, with the door open a crack so she could hear things. Another time I was observed with the nurse in the room.
For medical studies, I've had several. One I remember involved trying not to let any of my penis touch the opening of the container. Another they had me put a disinfecting brown paste all over the head of my penis beforehand.
A couple times, for studies, I've had to collect my urine for multiple days, or even a whole week. They gave me this gallon sized container to use, which I brought back to the hospital.
I've heard of drug tests where the person had to strip naked, and then be observed giving the sample. Those involved people who had been arrested, or already convicted of some crime.
There are all sorts of gadgets you can buy to conceal someone else's untainted urine in a vial or small container, which you then use instead of your own urine. I've seen something which had a small tube which ran from a container under your clothes, and then along under your penis or vagina, and was intended to look as if you were actually voiding into the test container.