A national ID card scheme has existed for many decades. It’s called a passport.
There is no reason a digital equivalent can’t be made using the passport system, and it can be left optional, just like passports are optional.