Is there any legal way to fly an inline twin-engine aircraft with a single-engine certificate? Is there any legal way to fly an inline twin-engine aircraft with only a single-engine endorsement? For example, if it's an ultralight or amateur built?

I understand Rutan's Defiant was an inline twin that could take off, fly and land with either the front engine, rear engine, or both.

I assume you can do this in a twin inline ultralight as there is no twin engine ultralight endorsement in USA or Canada.

I'm asking about the ultralight or amateur built categories in the USA or Canada, not the US LSA category as I understand they are single engine only.
Under United States Part 103 ultralight category, with no license or aircraft certification requirements as long as the the limitations of the category are met (dry weight, fuel capacity, single seat, and level flight maximum speed, permitted flight locations), you can do anything you like.  Whether it's safe or a good idea is up to the pilot.

Last time I checked, Part 103 requires a dry weight (with engine, no fuel, no pilot) under 254 lb, no more than 5 US gallons (though actually called out in liters) fuel capacity, and level flight speed limit of 55 kt (about 62 mph).

I can't answer relative to Canada, as their regulations concerning ultralight/microlight aircraft differ from those in the USA.