To solve my problem, I found the following solution by reading this page:
<script type="text/discourse-plugin" version="0.8">
const specialTopicUserId = 1000;
api.decorateTopicTitle((topicModel, node, topicTitleType) => {
if (topicModel && topicModel.user_id === specialTopicUserId) {
$("#topic").addClass("anon");
}
});
</script>