To insert Salesforce Knowledge Article Data Categories Assignment using Apex, we have to make use of knowledge__DataCategorySelection object/entity.
Sample Apex Code:
knowledge__DataCategorySelection objDCS = new knowledge__DataCategorySelection(
DataCategoryName = 'FAQ',
DataCategoryGroupName = 'General',
ParentId = 'ka04W00000171mjQAA'
);
insert objDCS;
ParentId: Id of the Salesforce Knowledge Article
DataCategoryGroupName: Data Category Group Name
DataCategoryName: Data Category Name