Testing if a sample fits into an existing cluster
The way to do anomaly detection with clustering is to compute the distance to each the fitted clusters. If a new sample has a distance above a certain threshold for all clusters, then it is considered an anomaly.

For KMeans the distance would be the distance to the center of the cluster. And the threshold to use is a new hyperparameter.

For DBSCAN one would typically compute the distance to each Core point in a cluster, and find the smallest distance. DBSCAN already has a distance threshold eps used during fitting. But to allow tuning sensitivity of the anomaly detection without redoing the clustering, you may want to use a threshold of eps*ratio, where ratio is a new hyperparamter.