To add custom fields to models (topics, categories, groups), the following topic from @angus really lays it out as well as you’re likely to find:
He has put together some sample code specific to topics and categories - I believe the code translates generally well for adding custom fields to groups as well.
This post from me on that topic lays out how I’ve used the resource that Angus has put together: