Short answer: you need a fuel injector that can handle injection into the highly-compressed air. Longer answer: https://www.britannica.com/technology/diesel-engine/Fuel-inj...
In modern engines you have other options such as an electric piezo stack hammer to force the fuel.
Common high pressure rail injectors have a separate high pressure pump connected to engine elsewhere and the injectors just turn on and off fed by a high pressure common rail.
The injector itself can be actuated mechanically or via solenoids or piezo, but there are no injectors that create pressure electrically that I know of (the closest I have seen are voicemail medium pressure gas injectors used in ETEC engines). That is the electric part of the injector only lets the fuel through, it does not force it.