Yes. This is known as a knn classifier. Knn classifiers are usually worse than other simple classifiers, but trivial to update and use.
See e.g., https://scikit-learn.org/stable/auto_examples/neighbors/plot...