We have insert a record into FeedItem object and set the Group Id in the Chatter Group to insert Chatter Post to a Chatter Group using Apex in Salesforce.
Sample Code:
FeedItem objFI = new FeedItem();
objFI.Body = 'Testing';
objFI.ParentId = '0F98c000000VNtXCAW';
insert objFI;
Output: