Can I switch off my parking sensors when I attach a trailer?

This depends on the wiring harness used:

Some wiring harnesses have to be programmed to the vehicle using approval/coding; this automatically disables parking assistance.
You can also order an expansion set for some Erich Jaeger wiring harnesses to switch off parking assistance.
Other wiring harnesses have a multi-function control module with connection options which allow universal disabling of parking assistance using the circuit diagram supplied.
It is also possible that your vehicle has already been fitted with a switch or button on the dashboard to disable parking assistance manually.