The most famous example of a collaboration between scientists/mathematicians during World War 2 is the Government Code and Cypher School (GC&CS), an intelligence organisation which had the task of decrypting secret communications of the Axis Powers. The intelligence obtained was termed as "Ultra".
During the Second World War, GC&CS was based largely at Bletchley
Park, in present-day Milton Keynes, working on understanding the
German Enigma machine and Lorenz ciphers. In 1940, GC&CS was
working on the diplomatic codes and ciphers of 26 countries, tackling
over 150 diplomatic cryptosystems. Senior staff included Alastair
Denniston, Oliver Strachey, Dilly Knox, John Tiltman, Edward Travis,
Ernst Fetterlein, Josh Cooper, Donald Michie, Alan Turing, Gordon
Welchman, Joan Clarke, Max Newman, William Tutte, I. J. (Jack) Good,
Peter Calvocoressi and Hugh Foss.
Apart from the famous British mathematicians like Alan Turing and Gordon Welchman mentioned above, mathematicians from different countries (mainly the Allies) were also directly or indirectly involved in the work at Bletchley Park. A few notable among them are Marian Rejewski (Polish) and Solomon Kullback (American). In fact, it was Rejewski and his fellow Polish mathematicians who first cracked the Enigma cipher. Welchman in his book The Hut Six Story: Breaking the Enigma Codes has written, "Hut 6 Ultra would never have gotten off the ground if we had not learned from the Poles, in the nick of time, the details both of the German military version of the commercial Enigma machine, and of the operating procedures that were in use."
The collaboration was a success and it is even mentioned on Wikipedia that:
Many commentators say the flow of Ultra communications intelligence
from the decryption of Enigma, Lorenz, and other ciphers, shortened
the war substantially, and might even have altered its outcome.
After the Second World War, in June 1946, GC&CS was renamed the Government Communications Headquarters. However, the work which was done at Bletchley Park remained a secret for a long time after the war!