How to group categorical columns into similar types? (Forgive me if the question is ill put. I am a novice in data science. Please comment or edit so that the question can be improved)

I have a dataset where we have to predict the future sale of a shop. "City' is one of the columns. The problem with 'City' is that data provided per city is very uneven in size(detail of only 1 shop in one city while giving detail of nearly 50 shops in another) Moreover many cities which are not present in train are present in test.

My plan is, based on other columns in train, I will find which cities are similar to each other so that I can classify those cities as a single group. (Logic is, say area, demand for an item are similar for city 1 and 3 so the sales in both of them will be similar.)

I can think of KmeansClustering or aggregated features. But I am not exactly sure how to achieve this. Please suggest some ideas, what are some good ways to deal with such cases.
although i don't quite understand your question. you don't have any business in worrying about data values in train and test sets, they are two different datasets after the split was done, as long as the features are the same, the content shouldn't be your focus. this is why scaling is done after splitting the dataset