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.