There are multiple ways, it depends what exactly you are trying to achieve.
If you want to write the feature from scratch using the Flarum extension API, you would indeed add new columns with database migrations, make the value visible through the serializer extender and make the value editable through saving events.
If you don't want to write/maintain an extension, there are multiple extension that lets you manage custom user attributes, including FoF Masquerade, Flamarkt Taxonomies and Kilowhat Formulaire. All those extensions edit their data through the REST API so you can also set values using the same REST API from a script if you need to.