What you've stated in your post isn't actually a trope, but a combination of several. To borrow from tvtropes.org, these include "The Old Dark House", "Locked Room Mystery", "On One Condition", "Ten Little Murder Victims" and/or "And Then There Were None". I'd add a few others in there but, on second thought, I should probably reserve those for my comments.
Here's the plot you described: The various heirs to an estate/inheritance are summoned to a venue. Where, according to the terms of the will, they must spend a requisite amount of time in order to lay claim to the riches.
Some "earlier" versions of it in the movies:
Two on a Guillotine (1965)
Duke Duquesne, is a very eccentric magician and due to his lifestyle
his two-year-old daughter is sent away to live with an aunt (living
there for the next twenty years). News of her father's death brings
Cassie Duquesne back to Los Angeles to attend his funeral. The
following day, she is told he left a rather odd will. She will
inherit her father's estate on the condition that she stay in his
creepy palatial mansion for seven nights in a row - alone.
The Indian Scarf (1963)
When a wealthy man dies, his avaricious relatives look forward to
inheriting all his money. However, he leaves a provision in his will
that they all must spend a week together in his castle before they
will be able to inherit anything. An alternate synopsis reads:
The will of a deceased statesman, requires his heirs to spend six days
and nights in his country home, where, one by one they are strangled.
Bring Me the Vampire (1963)
A group of would-be beneficiaries gather for the reading of a will,
and discover that they must spend the night in a spooky castle to
gain their inheritance.
No Place Like Homicide! (1961)
Ernie's uncle Gabriel has just died but to claim his inheritance he
must spend the night in the ancestral home with the rest of his
relatives. Before long the guests begin to drop dead.
The Phantom in the Red House (1956)
A bunch of greedy relatives get together for the reading of a rich
man's will. They all have to live in his scary mansion for three
days and on the third day they can search for his hidden fortune.
Meanwhile there is a phantom in a red cloak sneaking around through
the secret passageways that all spooky houses have in movies and
sticking daggers into peoples backs.
One Body Too Many (1944)
Insurance salesman Albert Tuttle arrives at the Cyrus J. Rutherford
estate to sell the millionaire some life insurance. Rutherford is
already dead and his heirs have gathered at the mansion to hear the
reading of the will. Rutherford's will won't be read until he is
properly entombed and the heirs are forced to stay on the premises or
be denied their inheritance. Tuttle soon finds himself mixed up in
shenanigans involving Rutherford's niece, secret passages, a missing
body and murder.
As you can see, this particular theme lent itself quite easily to horror-comedies. Hardly a surprise, considering there were so many related as well as disparate elements in the blend.
Movies with variations on the theme:
Murder by Invitation (1941)
The relatives of Cassandra "Cassue" Denham, an old unmarried woman
living in New York who is good for three million dollars, try to make
a judge declare her unable to take care of herself financially. The
attempt fails, and in charge of handing in the petition is Cassie's
nephew Garson Denham, a lawyer. Instead he summons a newspaper
columnist, Bob White, and his girlfriend, Nora O'Brien, and tells them
he has been invited to stay a week at Cassie's estate up in the
mountains. The invite states that any relative not arriving on the
specified time at midnight on Friday will be excluded from her will.
Haunted Spooks (1920)
The opening sequence has an uncle reading a telegram regarding a will.
It tells him that his niece Mildred will inherit the house and
plantation as long as she lives there for a year with her husband. He
tells his wife that they must scare them out of the house.
There are a couple of other movies I'd like to highlight. Even though they don't deal with a will or an inheritance, they do involve an ominous invitation. The first one features a treasure hunt which is merely a ruse to exact revenge. The second one has a group of strangers who are invited to a party. And the reason they bite is because they're plain curious i.e. there's no money in it for them.
Movies featuring a mysterious invite:
Fog Island (1945)
Leo, a former convict, is living in seclusion on an island with his
step-daughter, the daughter of his late wife. Leo was framed by a
group of former business associates, and he also suspects that one of
them killed his wife. He has invited the group to his island, tempting
them by hinting about a hidden fortune, and he has installed a number
of traps and secret passages in his home. He is aided in his efforts
by a former cell-mate who holds a grudge against the same persons.
When everyone arrives, the atmosphere of mutual suspicion and the
thick fog that covers the island promise a tense and hazardous weekend
The Ninth Guest (1934)
Eight strangers are invited by a mysterious unknown host to spend the
night in a penthouse apartment. The eight (5 men, 3 women) are wined,
dined, then greeted by their host's voice via a radio broadcast. The
voice announces that before the night is over each one will be
systematically murdered unless they manage to outwit their ninth guest
Death. Based on the mystery novel The Invisible Host (1930) by Gwen
Bristow & Bruce Manning.
This is by no means a definitive list. As far as I can make out, there are stories based on this theme which date back to the 1910s and 1920s. But, hopefully, this post should point you in the right direction.