I am struggling to make a proper configuration if such can be made.
we have one back-end application, that runs two services:
I am trying to deploy this service as an ECS task but I am not able to configure this in such way, that both ports will be exposed within a single target group and a single registered target, so I will be able to route the traffic through the load balancer.
A single target group can only forward traffic to one port. You need to create two target groups, one for each port, and two listeners on the load balancer, one that forwards traffic from your API port to the REST API (via the first target group), and one that forwards traffic on your WebSocket port to the backend WebSocket service (via the second target group).
You would then register both target groups with the ECS service, as documented here.