Undercover cops can legally pull you over if they want too.
But in most cases the undercover cop will just follow you and have a marked police car pull you over if they want to pull you over.
In order for you to legally have to stop for a police car when pulling you over the police car must be marked and easily identifiable as a police car.
There have been instances where people fake being police in unmarked cars and pulling people over and then robbing or killing them.
If you don't feel safe about the situation that an unmarked police car is trying to pull you over then just keep moving and try to contact 911 and let them know that an unmarked car is trying to pull you over.
They will then let you know if it's actually a real police officer or not and let you know if you should pull over for them.