First the algorithm looks for non capital cities, then for cities that don't already have a religion present, then it looks for the highest population size, but keep in mind that there still is a bit randomness thrown in so you can't 100% guarantee that a certain city will be the one.
To maximize the chances of a certain city becoming a holy city you can try to keep it religionfree and maximize its population, that means in practice spreading religions everywhere else and whipping all other cities but the capital (which already has an extremely small chance of becoming a holy city) a few turns before you found the religion.