There are a couple ways to do this. First, we have an API call that can log a user out of all their active sessions. Also, you can use the platform command like this:
$ cd <your mattermost path>
$ sudo bin/platform user deactivate username1
$ sudo bin/platform user activate username1
Replace <your mattermost path>
with the path to your Mattermost installation, and username1
with the username, user id, or email of the user you want to log out. If there are more users just separate their identifiers with spaces
You can find out more about the Mattermost command line tools here.