Question: I have this question: since the CMO on board a starship is generally the captain's own private physician, is there anything in the regulations that says a CMO can't call the captain by his real first name in certain instances? Like when the captain feels stressed, or is afraid about something?

I"m not talking about meeting him/her in a bar or on the street and saying "Hello...." But when they're on duty and there are times when the captain's first name is used.

I understand that some would answer that for the CMO to call the captain by their first name should only come after they've developed a lot of trust over the years, but I contend that sometimes the CMO has that prerogative to call the captain, or even a crewman, by his/her first name during a medical procedure or when they're alone and the person wants to talk to him privately about a medical issue..

Answer: 
How the captain is addressed, based on the various series we have available, is dependent on your relationship with said captain.
As you said, Bones and Kirk have an informal relationship.
Most captains in the Star Trek franchise (who are a main character) have at least one member of the crew they are particularly close to, usually due to a prior relationship. This is good for storytelling.
Picard has Beverly Crusher, who is indeed his Chief Medical Officer. She regularly uses his first name, and he reciprocates.
Sisko has Jadzia Dax, who regularly calls him Ben or Benjamin, but she is not his CMO.
Janeway has Tuvok, who I don't recall ever addressing her informally, but Chakotay does on quite a few occasions. Note, not all first officers are in the habit of doing this, with Riker very rarely using Picard's first name for example. I think Chakotay is supposed to be closer to Janeway due to their isolation as commanding officers far away from the rest of Starfleet. Back to the point: neither Janeway or Sisko's CMOs have a regular tendency to use their captains' first names.
Captain Archer has this closer than usual relationship with his first officer, who doesn't often use his first name, but neither does his CMO.

To summarise: Some characters have a close, somewhat less formal relationship with their captain (to a point) and are on first-name terms. This appears to be the Chief Medical Officer on more than one occasion but it does not seem that there is any regulation that accounts for this. Indeed, some doctors would appear somewhat out of character in treating their captain informally in my opinion.

Note: The Starfleet CMO has some intruiging rights and responsibilities, such as the ability to relieve the captain of duty in extreme conditions, but this does not mean that they out rank him/her. Saying that, I'm sure they can address the captain however that captain feels comfortable during intimate medical procedures!
In most cases, the medical staff on a starship are outside the chain of command as they are specialists with their own command structure headed by Star Fleet's Surgeon General. In some cases, medical officers can take command courses if they wish (both Deanna Troi and Beverly Crusher do so at one point if I remember correctly). The CMO is generally considered to be the Captain's peer as he or she would be the only officer that is not considered to be wholly under the captain's command since the CMO does have the legal authority and duty to relieve the captain if he or she becomes physically or mentally unable to perform his or her duties. 

Whether or not the CMO addresses the captain by their first name would be up to the individuals involved. Kirk was more intimate with his senior officers and tended to be more informal, not to mention he had a much smaller crew (465 including 75 officers) while Picard was more traditional and formal. Picard almost never used anyone's given name and usually referred to his CMO as "Doctor". Picard also had a much larger crew requiring a greater degree of formality to ensure discipline was maintained (Enterprise D had a total crew of 1014 including 310 officers excluding the civilian family members which brought the total number on board to around 3000 if I remember correctly).