The two leaders signed the deal in the port town of Stephenville, Newfoundland.
The first deliveries are expected in just three years.
Earlier on Tuesday, the two heads of government attended an economic conference in Toronto.
Canada and Germany sign hydrogen deal
Germany seeks options as it tries to move away from Russian gas
The trip to Canada, Scholz's first as chancellor, comes as Germany looks for ways to reduce its reliance on Russian gas.
At a press briefing in Toronto Tuesday, Scholz said Canada was the partner of choice, as Germany moves away from Russian energy imports at "warp speed."
"Your country has almost boundless potential to become a superpower in sustainable energy and sustainable resource production," he said.
The pair also said they would discuss the possibility of Germany buying Canadian liquefied natural gas (LNG).
To that end, Trudeau said on Monday that "we are looking at every possible different way to help out the German people and Europeans in the short term as they face a real challenge this coming winter."
"Canada will play a very, very central role in the development of green hydrogen," Scholz said at the same joint press conference. "That's why we're very happy that we can also take this opportunity to expand our partnership in this field."
How does hydrogen work as a source of energy?
Both LNG and green hydrogen are seen as medium-term solutions and will not be able to help Germany in the next few months. Canada does not yet have the means to export LNG internationally, and the production of green hydrogen is still in its infancy.
The use of hydrogen does not produce greenhouse gases. To create it, water has to be split into hydrogen and oxygen, electrolysis that is only climate-friendly if sustainably produced energy is used.
In principle, hydrogen can serve as a basis for fuels to replace coal, oil, and natural gas in industry and transport. Because its production is very energy-intensive, hydrogen is currently still significantly more expensive than fossil fuels.
Sparsely populated windy areas such as Newfoundland are considered ideal for the production of green hydrogen.
German energy companies Eon and Uniper said on Tuesday that they had signed a memorandum of understanding with Canada's Everwind on the sidelines of the German-Canadian talks with the aim of importing hydrogen on a large scale from 2025.
Scholz called the agreement "an important step, not only for strengthening our bilateral economic relations but also for a sustainable energy supply for the future."
Trudeau and Scholz were also scheduled to take part in an online conference on Tuesday organized by the Ukrainian government. The aim of the summit is to mobilize international support for the return to Ukraine of Crimea, a peninsula annexed by Russia in 2014.
Both leaders spoke on Monday of their continued dedication to helping Kyiv fight Russian aggression.
es/rt (AP, dpa, Reuters)
While you're here: Every Tuesday, DW editors round up what is happening in German politics and society. You can sign up here for the weekly email newsletter Berlin Briefing.