A Trade Table is a file that controls an entity's trading UI and functionality. Vanilla example: Villager. As of right now, trading entities are often used to simulate UI blocks.
Adding the trading AI to an entity:
This goal is accomplished via minecraft:trade_table or minecraft:economy_trade_table components. Both of them will open a trading UI from the given path, but the economy trades component has some more options referring to some Village and Pillage trading mechanics. Other AI goals you'll need are minecraft:behavior.trade_with_player, optionally minecraft.behavior:trade_interest (allows the mob to hold/offer an item) and, potentially, "minecraft:trade_resupply": {}.
For a simple trading UI, trade_table + trade_with_player components should do the trick.
1) Add "minecraft:behavior.trade_with_player": {} to your entity's components.
2) Copy the following code into a component group of your entity. I'll call mine "tut:trader";