Is it possible that in case of some very serious emergency, a commercial airliner such as the B777F could be used for dropping bombs or to serve some other fighting purpose? I am simply asking about this from a technical standpoint.
Retrofitting is (as the comments to your post have already stated) rather difficult and unusual. In addition, the quality of service from such an aircraft you could expect to get would most probably not be great. Analogy: Try changing your minibus for 9 people into minivan for freight and industrial work.
It is also worth mentioning that the difference in operation is substantial between bombers and commercial jets. You would be better off using something that is not that complicated, like a Cessna Caravan for instance.
I think that energy, time and money would be better spent on building more dedicated aircraft. Changing the commercial ones is also not trivial and will require engineered changes.
It is however fully possible to design a military derivative of a commercial jet. The Boeing P-8 Poseidon is an example of this, being based off the Boeing 737 with the necessary modifications.
The armament is also fairly extensive:
5 internal and 6 external stations for AGM-84H/K SLAM-ER, AGM-84 Harpoon, Mark 54 torpedo, missiles, mines, torpedoes, bombs, and a High Altitude Anti-Submarine Warfare Weapon system[
It should be noted that some civilian aircraft do have military systems fitted (and not just radars like AWACS). The Israeli airline has a laser-based missile defense system fitted to its airliners. (They wanted to use flares but apparently you can't drop flares at a commerical airport due to fire risk, so they got a laser-based system instead).
The package is slightly different from the one sold to the miltiary as it has to be completely self-contained: it can't use the interfaces - for example to the missile warning systems - on a warplane as the airliners don't have them.
If you were going to use bombs I suspect you might roll them out of the back of a cargo plane. During the Falklands War (1980s) there was some talk about Argentina possibly attempting it, but I don't think they ever did.
Converting pretty much any passenger hauler into a bomber would be quite an exercise. You would have to add pressure bulkheads aft of the flight deck, rebuild the bottom of the fuselage to allow for doors, add considerable structure to hold the (very heavy) bomb racks, and probably remove the floor - rather tricky if the floor is also holding the fuselage together.
Missiles on the wings would be comparatively easy - they are not as heavy and don't require major mods to the pressure hull.
A "serious emergency" indicates urgency, and that gets met with existing aircraft. The time taken to modify a 777 into a bomber would be fairly close to building a new bomber. Although if it's a protracted war of attrition* I would expect Boeing would quickly design a new one based around the 777's tooling so they can get them out the door quickly.
It is very easy (and common) to use passenger haulers as troop transport. Conversion to AWACS is nowhere near as complex, I suspect someone already has plans in a file somewhere to do just that. And the USAF already uses DC-10 freighters as tankers - the boom is a not-overly-complex conversion and probe-drogue systems are almost bolt-ons.
Before anyone comments about it, the DC-10 used as a water bomber is very different from dropping explosives. Water is a distributed load, and releasing it doesn't require half of the bottom of the plane to open up - it flows out through ports that can easily have structural members running across them.
* World War II would be a good example. Evenly-matched belligerents, whoever has more resources usually wins. If WWIII goes nuclear it will be over in an hour or two.
While commercial aircraft can obviously be used for transport missions (transporting troops or military cargo) unchanged, I believe the question is really about using commercial airliners for combat missions.
I am not entirely sure if light business jets like the Learjet 35 meet the definition of a 'commercial airliner' in the question, but these civilian aircraft have been pressed into service for military missions during the Falklands war.
Learjet also make military versions of 35 series; the primary change being the addition of hard points under the wings allowing the carrying of military payloads including weapons.
Similar conversions include the older turboprop Fokker F27 conversion:
So aircraft can be lightly modified to perform combat missions if they have the ability to carry external loads and some avionics to support the loads. However such aircraft would lack features found in military aircraft such as ejection seats.
For what its worth Air Force One is operated by the United States Air Force and is built on the common 747 airframe. Although the plane is highly customized and lets be honest only servers a single military purpose it is, for what its worth a civilian plane (in a sense) that has been converted to a military function.
Aircraft development seems to go the other way more often. Example: the Boeing 377 Stratocruiser was developed (indirectly) from the WWII B-29 bomber. It's expensive to develop a new platform; military budgets seem to be large enough for such undertakings on a frequent basis. Not so in the commercial world. Revolutionary designs like the B-707 and B-747 come along, but even they were started with military contracts in mind as much as civilian markets.
The USAF's fleet of E-8C JSTARS reconnaissance aircraft were all converted from 707-300 series airliners, some of which had already seen service with a half-dozen airliners before being purchased by the USAF for conversion. Using second-hand airliners wasn't exactly cheap however, as the reported unit cost of one E-8C was still 244.4 million in 1998 US dollars (equivalent to 388.1 million in today's dollars)
As an example, here is a photo taken in 1970 of a 707-338C operated by Qantas Airlines with MSN 19622:
And here is that same aircraft (post-conversion) pictured 50 years later flying out of Curacao on a counter-narcotics mission:
In the 1980s there was a proposal for a Cruise Missile Carrier Aircraft (CMCA) version of the Boeing 747, which could have carried and launched around 70-100 AGM-86 ALCM cruise missiles with nuclear warheads. This was actively considered by the USAF but rejected in favour of continuing development of the Rockwell B1 bomber.