You can do this with /api/v3/community/hide, or in the database by setting community.hidden. Unfortunately this is not available from lemmy-ui yet.
From a comment by nutomic: https://lemmy.ml/comment/16090216
Context: https://lemmy.ca/comment/13891923
Not sure if that feature was known to everyone, so sharing this as its own post.
No this only affects your local instance. So it doesnt affect how your communities are shown on other instances, but it lets you hide remote (or local) communities from All.