i'm guessing it is a manual trans. It could be any number of things,but u might want to check oil level. Need to get it up on ramps or something and look for anything that could be loose, like plastic shields under car,be very careful when getting under a car

HelloTheengine
and transmission in this cars drive train are fully
electronically controlled by a computer called the PCM (Power Train
Control Module). Whenever a problem like this occurs the computer
stores a record of the problem (there are of course some exceptions
to this, like the fuel pump for instance) in the form of a fault code
in its memory, to read these fault codes you must have the systems
memory scanned with a special tool. Once the fault code(s) are read
you then must perform the appropriate diagnostic testing to find and
resolve the problem(s) DO NOT REPLACE ANY PARTS UNTIL THE
DIAGNOSIS & TESTING IS COMPLETED.

That's really bad ... First of all check oil level when its cold... The clanking sounds are your valves running dry. This will cause massive damage the heads. If you oil is low fill it back up & check the engine for leaks & hope there is not valve damage. If the oil was low and you filled it & you still get the clanking noise the valves are permanently damaged & the head/heads & valves will need to be replaced.. Big costs

Your description sounds serious. The next step is to check the oil level, then check the oil pressure with an external gauge. If the pressure is low, the news is not good and you need to disassemble the engine until you find the issue. The clanking does description does not sound good.