The electrical components in modern engine compartments are not designed to be waterproof against the pressure that pressure washers have.
That said, if you use common sense you can usually get away with it. Even when a component gets wet, the heat in the engine compartment will work to dry it out after some time. The real problems occur if the water corrodes electrical components.
I get a fault with my oil pressure sensor if I pressure wash my engine. I am sure the oil pressure is good. If I disconnect the sensor and drive about a day and then reconnect it, everything is fine. For this reason, I seldom wash the engine and I am very careful when I do.
One thing you can do to help is to apply dielectric grease (Permatex Tune-Up Grease) inside the connectors before you wash the engine.
The real question is how risky is it to pressure wash an engine. The answer is, it is somewhat risky.