In the US, just after passing your exam for Technician, General and/or Extra if you didn't have a call sign to begin with, can you request a vanity one right away or do you have to wait until one is assigned and then change it?
You will have to be assigned a call sign first. To apply for a vanity, you will need an FCC Registration Number (FRN). The rule is that you cannot receive a vanity call sign from a call sign group for which your operator class is not eligible. For example, if you are operator class T (technician), you can only receive call signs from groups C & D. If you request a call sign from groups A or B, your application will be dismissed by the Commission. So, technically you must be licensed with a call sign first. The process is not instantaneous. It takes 18 days.
There is no requirement that you have a call sign to apply for a new one. The requirement is that you are of sufficient class to hold the call sign you apply for when the vanity application is processed.
It takes 18 days to process a vanity application and around 10 days to process a new license after you pass your test.
So yes, you can apply for your vanity call sign as soon as you know what license class you qualified for. As long as your license is processed in a timely fashion, you will have your license and original call sign by the time your vanity application is processed.