You can determine whether a particular task is a kthread or not by looking at /proc/<PID>/stat. More presicesely, according to man 5 proc the 9th field of this virtual file contains the kernel flags for the process. In case of a kthread, the flags will have PF_KTHREAD set.
Here's an example of a Bash script that takes a PID as argument and checks if it's a kthread or not:
#!/bin/bash
read -a stats < /proc/$1/stat
flags=${stats[8]}
if (( ($flags & 0x00200000) == 0x00200000 )); then
echo 'KTHREAD'
else
echo 'NOT KTHREAD'
fi
This isn't really simpler than just doing ps u -p <PID> and checking for [], but it's a pure Bash solution nonetheless.
There are also some more "tricks" which can be used to identify a kernel thread, it's easy to modify the above script to use one of the methods highlighted in this post.