Trackpad works for Diagnostic Test. Can I rule out it has a hardware problem? If a MacBook Pro trackpad is able click and scroll, swipe, move cursor, etc. during a during Diagnostic Test (when I  startup holding down the  D) then, am I able to rule out that it has a hardware problem? 

The test results show I have no problem. Its just that during the the test my track pad works.
If a MacBook Pro track pad is able click and scroll, swipe, move
  cursor, etc during a during Diagnostic Test (when I startup holding
  down the D key) then am I able to rule out that it has a hardware
  problem?


For the most part, yes.  It's extremely rare/unlikely that hardware will work fine in one environment, then completely fail in another.  In cases like this, it tends to be a software issue (i.e. conflicts with other software, bad drivers/kexts, mis-configurations, etc.)

Your next step in diagnosing the problem will be to...


boot into Safe Mode
boot into Recovery mode
boot a clean and/or older version of macOS from a different volume (a 16 or 32GB Flash drive is more than sufficient)


The idea with any/all of the above is to get the OS as close to "factory" as possible for testing/diagnostics.  Safe mode isn't always "factory fresh", but Recovery and a clean install on a different volume is.  If you happen to have an older version of macOS you can install on an external volume, then you can evaluate whether it's your newest update that's causing the issue.