Firstly recognize that the term 'The Axis Powers' represents organisations comprised of a large number of people. Those individuals had their own hopes, fears and goals and, those that did, recognized the futility of the war at different times and for different reasons. But organizations tend to have their own inertia and continue their policies even when it's members have lost confidence.
Some in both Germany and Japan felt that the war was un-winnable from the start. Some in Germany saw the invasion of Russia as the point of no return, Rudolph Hess who fled to England six weeks before^[1] the invasion might be counted in that group.
When Field Marshal von Rundstedt was re-appointed to command in the West in September 1944 his subordinates asked him what they should do to rectify the situation, "End the war of course!" was his reply. But he continued to fight anyway. Many German officers and soldiers felt by that point that they were just buying time for a miracle to happen. Either the new wonder weapons would arrive or the Allies would fall apart and each would seek a separate peace.
Hitler himself announced to people within earshot several times that "this is the end"; each time he regained his composure afterwards and carried on as if all he needed to do was appoint a new general or fire an old one.
It can be argued that Nazi Germany, as an organization, never recognized that the war was irretrievably lost until it disintegrated in April/May 1945.
As far you can say that any organization has a 'realization' the government of Japan finally acknowledged the inevitable in June 1945 and opened negotiations with the Soviet Union. But it took the atomic bombs and the Soviet invasion of Manchuria two months later for them to accept the Unconditional Surrender requirement.
^[1] As a senior Nazi party member, Hess was well aware of the invasion planning.
Sources : Martin Gilbert's The Second World War and William Schirer's the Rise and Fall of the Third Reich have very illuminating insights into the minds of the Nazi leaders.