Create a file in the groups format used by yum
Tell createrepo to include that group file in your repository.
Step 1
You can either open a text editor and create the groups xml file manually or you can run the yum-groups-manager command from yum-utils.
Run the groups-create command like this:
yum-groups-manager -n "My Group" --id=mygroup --save=mygroups.xml --mandatory rpm1 rpm2
And you'll end up with a file like this:
mygroup
False
True
<display_order>1024
My group
glibc rpm yum
Step 2
To include this in a repository, just tell createrepo to use it when making or remaking your repository.
createrepo -g /path/to/mygroups.xml /srv/my/repo