Yes it can be done but you need the secondary account to actually buy the game digitally and it will be available for the primary too. Although only one of you will be able to play at any one time.
But beware that there is a remote possibility that Sony will suspend the accounts for violating the terms.
Apparently the way SONY intended Game and psn+ sharing to work ON PS4s IN THE SAME HOUSEHOLD....
Person A has a psn + account, and buys the games. Person B does not have psn +.
The ps4 belonging to person B should be made person A's primary ps4,
The ps4 belonging to person A should be made person B's primary ps4.
Person A, as the psn + holder can play online on any ps4 anywhere, person B can play online because thier ps4 is down as a psn + holders primary.
This works the same way with game DLC, so that two people playing the same game in the same house do not both need to purchase the DLC.
Obviously this works even if the ps4s are in different houses, but that may be against rules and terms of service et.c, so i wouldn't recommend it.