There are so many variables, hundredes if not thousands, that I think it is a difficult comparison.
The basics are that an engine converts chemical/thermal energy into mechanical energy. Assuming 100% volumetric efficiency, a 6L 4 cyl engine should consume the same amount of air/fuel, and liberate as much heat as a 6L 12 cyl engine at the same rpms. I tend to think of torque as kind of a measure of the volume of air/fuel the engine can consume per revolution, i.e, the torque is related to the displacement of an engine, and how efficient that engine can convert thermal energy into mechanical energy.
Of the thermal energy liberated, a general rule of thumb is 1/3 goes out the exhaust, 1/3 goes out the radiator, and 1/3 goes out the driveshaft. A higher compression captures a bit more of the energy that wouold be lost through the exhaust.
The engine is not 100% efficient itself, and some of the the initial mechanical energy is lost to heat/friction, such as ther piston/rings rubbing against the cylinder wall, heat production in the bearings, parasitic loss of valve train,
oil pump, alternator, etc. The more you can reduce internal friction of the engine, the more energy makes it out of the driveshaft.
The mechanical design/relationship of various parts of the engine impact how this mechanical energy is transferred out to the driveshaft, such as rod length/stroke ratio, bore/stroke ratio. Generally, a longer stroke engine generates more torque, hp, at low rpms which is what you want in a truck engine. A larger bore than stroke engine is better suited for higher rpms.
A smaller combustion chamber allows for better, more efficient and quicker combustion, allowing for I think better energy conversion, and also allows for higher rpm efficiency.
HP is torque X RPM's, so the hgiher an engine can run at maximum efficiency allows you to make alot more power, do more work. Therefore HP is related to size of the engine ( max torque), and the rpms of near maximum efficiency ( determined by capability of heads, intake, exhaust)
This is very simplified, but kind of how I understand how an engine operates.
Assuming everythihg else equal (adequate head flow, compression, ignition), I would guess the engine with more pistons, of overall same displacement, would have better combustion efficiency and produce ( convert more of the thermal energy) into more power, optimizing timing of each engine. Having too many pistons will increase friction and reduce output.
some other things I've heard that a straight 6 engine and a V-12 engine design offer near perfect or perfect balancing. A V-10 design optimizes engine output, slightly better than a V-12 or a V-8, with regard to efficiency, internal friction, etc.
Ferrari made engines in the 1960's, some of 12 cylinder design, and some of 6 cylinder design, and maybe 4 cylinder as well, of the same displacement, in the same race. The 12 cylinder versions were generally faster, but in some races, the 12 cylinder cars broke down, and the larger piston versions ended up winning the race. I can't remember the specifics.