Customize slug response

Hello everyone! This is my first time writing here. I have a question and I would like to know if you can help me.

I’m trying to change a little bit the way the slug is generated. To give a little more context this is the approach I have:

I have two content-type: Post and Categories.

Both are related and both have a slug field that for each is generated by the title.

But I need to make the slug of the category related to the post concatenate with the slug of the post and generate something like this:


I have tried to modify the schema.json of the posts but I have not been able to get it to take the slug of the category.