There are several non-discrimination tests that must be satisfied. 410(b), 401(a)(4), and 401(a)(26) are the big ones. The 40% rule is in 401(a)(26), so yes, you can create a DB plan that only benefits 2 HCEs, but you still need a way to satisfy 410(b), 401(a)(4), and the Top Heavy rules of 416. IOW, you will need a generous DC plan for the NHCEs.
I wouldn't recommend creating an HCE only DB plan with a group this small. If/when someone leaves, or they hire a few more people, you will need to add people to the DB. Typical design would be include everyone in DB, give small benefit to NHCEs in DB plan (enough to "benefit"), and use the DC plan to satisfy the other requirements.
Also, make sure that no one is "otherwise excludable", which might lower your count.