Both your sentences are not wrong, and both sentences don't differ much in terms of formality, in my opinion. But they would also both sound a bit uncommon language to a native speaker.
German safety labels rarely address the user directly, but rather use the imperative/infinitive form (This form is called "Freier Infinitiv" and is used like an impersonal imperative), thus:
Abdeckung in eingeschaltetem Zustand nicht öffnen!
or
Abdeckung nur in abgeschaltetem Zustand öffnen!
This is contemporary usage. If you want to ask "nicely", leave off the exclamation marks. After all, safety labels should be short, concise, and to the point. Some of such labels are sometimes even used close to idioms, like in
Packungsbeilage beachten!
which is a standing expression used on pharmaceutical products.
In a kind of well-aged/outdated way, you can sometimes still see safety signs in tramways saying
Suche beim Stehen festen Halt!
Here the passenger is addressed directly in imperative, and even in "Du" form - But that form is about 100 years outdated and sometimes laughed about today.