Easy. As you say, use a repeating group. Set a state on the repeating group called selectedItems.
Each time a user clicks on the pills, it will either add them or remove them from the custom state. You will need two workflows, one for when selectedItems contains current cells item and one for when selectedItems doesn’t contain current cells item.
Then when user clicks Confirm at the bottom, it saves the list of selectedItems to the database.