Is there any cockpit procedure used to avoid shutting the good engine, instead of the bad one (on fire, for example)?
Procedures exist

If you read about the Kegworth crash you will see that the pilot started to follow a procedure he has been trained on but was interrupted by an ATC call and failed to complete the procedure. The procedure involves checking the engine vibration meters and reviewing decisions.

So, yes, procedures exist.



Procedures vary

Procedures vary depending on exact aircraft model and on the airline operating the aircraft. Some airlines use more memory checklists than other airlines. So it isn't possible to list a specific procedure that is used by all pilots of multi-engined aircraft.

Identifying problems

Pilots don't start from the point "we need to shut down engine No 2" they start from some observable event like "smoke in the cockpit" (as in the example incident above)

There are instruments on the instrument panel that show engine temperatures, vibration and other parameters that should usually make it evident which engine is not performing normally.

Here's an example procedure - note that this isn't the one for the airline and plane model in the incident above but it is probably similar



Note the points


Eliminates No 2 engine as source ...
...
Eliminates No 1 engine as source ...