For the purposes of the resistance/immunity example in the original question:
"bludgeoning, piercing, and slashing from nonmagical weapons that aren't silvered"
The "weapons" portion of the example is actually sufficient to know that it does not apply against the example sources of damage, magical or not. The resistance only applies to specific damage type subcategories of weapon damage. None of the given examples are weapon attacks, so this resistance/immunity to damage from weapons does not apply to the given non-weapon examples in the question regardless of what type of damage is being done.
That said, errata has updated most (all?) instances of the given resistance/immunity example in the question to the following:
Bludgeoning, Piercing, and Slashing from Nonmagical Attacks that aren't Silvered
(Weapons -> Attacks)
Now it's clearer that the magical status of the attack itself should be considered.
The Sage Advice compendium provides the following checklist for determining if something is considered magical (see also: How do I know if an ability is magical?)
If you cast
antimagic field, don armor of invulnerability, or use another
feature of the game that protects against magical or nonmagical
effects, you might ask yourself, “Will this protect
me against a dragon’s breath?”
[...]
Determining whether a game feature is
magical is straightforward. Ask yourself these questions
about the feature:
- Is it a magic item?
- Is it a spell? Or does it let you create the effects of a spell
that’s mentioned in its description?
- Is it a spell attack?
- Is it fueled by the use of spell slots?
- Does its description say it’s magical?
Since the question's examples are all spells or spell attacks, they fall cleanly under the umbrella of being magical. As such, thorn whip and the initial spell attack of ice knife are considered magical attacks, which clearly bypasses the errataed resistance/immunity text. Damage dealt as an effect of spell that isn't related to a spell attack roll (like the damage of earth tremor) is both magical and not from an attack, so the resistance/immunity text also doesn't apply there.
It's also worth noting that there's currently no such thing as an attack that is both a spell attack and a weapon attack, as noted in answers to a question about how to refer to non-spell attacks.
There is no existing way to do it in the rules.
There might be ways that exist but if they do they are so obscure (splatbook feats from 3e for unarmed-strike only) that you might as well just houserule.
-4 is a good basis, because that is the same penalty as using an improvised weapon.
Change Weapon Damage, (Houserule)
By taking a -4 to hit, you may do a different damage type with a weapon than it normally does. Cutting with the blade of a rapier, bashing with the hilt of a longsword, you may change your damage type to one of; bludgeoning, slashing, or piercing for that one attack. You may change weapon damage types on any attack, even one which is part of a Full Attack action, or a Charge.
Class features or feats that specify a damage type ('a slashing weapon' etc) will not function if you use 'Change Weapon Damage' to change the damage type to a different one than the one mentioned in the class feature or feat.
Best Answer
Yes - It's Attacker's Choice
The dagger weapon entry says "P or S" for its damage type, as you mentioned. The important part is how you resolve the two types, which is here (emphasis mine):
You always get to choose which one you want, even when throwing it.
If you wanted to houserule it that it only does one type when throwing it, you certainly could. But it's not a core rule.