Anda mungkin hanya perlu mengubah sedikit kueri pertama:
return Post::selectRaw('Count(likes.id) + Count(comments.id) as total_count')
->withCount(['likes', 'comments'])
->groupBy('posts.id')
->orderByRaw('(Count(likes.id) + Count(comments.id)) desc')
->paginate();