This is not true. There is no biological reason why a vaccine wouldn't work on an infected individual.
What you say is a myth, mostly as a result of most vaccines being about accute infections, like smallpox. In those cases, there is no real idea in administering a vaccine to a person who is already ill, because by the time the immune system is ready with its strong specific answer (which is a matter of days), the patient would be either dead or cured by "natural" response to the virus.
There are already vaccines targeting (successfully) diseases with a long incubation period. Examples for this are tetanus and rabies. You get your vaccine after being bitten (by a rat for example), and you are OK.
In the case of rabies treatment, if the patient has not received the rabies pre-exposure vaccination then they must receive a dose of immunoglobulin (antibodies against the rabies virus) in addition to the rabies vaccine. Without it, the patient would die before their immune system would be ready to fight the virus. Receiving the dose of immunoglobulin gives the immune system enough time to start producing its own antibodies.
For this reason, travellers to countries where immunoglobulin may not be available are often advised to get the rabies pre-exposure vaccination before they go.